ios - IB_DESIGNABLE tintColor issues -
i'm getting ib_designable, , i've stumbled on issue.
when set tintcolor of custom view ib, rendered in right way in ib.
but when run on device displayed default tintcolor.
#pragma mark - uiview - (void)drawrect:(cgrect)rect { [self drawcircleradius:min(rect.size.width / 2, rect.size.height / 2) - self.linewidth / 2.f rect:rect startangle:self.startangleradians endangle:self.endangleradians linewidth:self.linewidth]; } #pragma mark - private methods - (void)drawcircleradius:(cgfloat)radius rect:(cgrect)rect startangle:(cgfloat)startangle endangle:(cgfloat)endangel linewidth:(cgfloat)linewidth { uibezierpath* bezierpath = [uibezierpath bezierpath]; [self.tintcolor setstroke]; [bezierpath addarcwithcenter:cgpointmake(rect.size.width / 2, rect.size.height / 2) radius:radius startangle:startangle endangle:endangel clockwise:yes]; bezierpath.linewidth = linewidth; [bezierpath stroke]; }
what difference? why displayed default tint color in device, , correctly displayed in ib?
update:
#import <uikit/uikit.h> ib_designable @interface pkcircleview : uiview @property (nonatomic, assign) ibinspectable cgfloat startangleradians; @property (nonatomic, assign) ibinspectable cgfloat endangleradians; @property (nonatomic, assign) ibinspectable cgfloat linewidth; @end
the issue on line
self.tintcolor = [uicolor defaultdwonloadbuttonbluecolor];
:
static pkcircleview *commoninit(pkcircleview *self) { if (self != nil) { self.backgroundcolor = [uicolor clearcolor]; self.startangleradians = m_pi * 1.5; self.endangleradians = self.startangleradians + (m_pi * 2); self.linewidth = 1.f; self.tintcolor = [uicolor defaultdwonloadbuttonbluecolor]; } return self; } @implementation pkcircleview #pragma mark - initialization - (id)initwithcoder:(nscoder *)decoder { return commoninit([super initwithcoder:decoder]); } - (instancetype)initwithframe:(cgrect)frame { return commoninit([super initwithframe:frame]); }
it seems settintcolor ib called before init... methods.
Comments
Post a Comment