ios - How I could get access to circles drawn in drawRect? -
so, have custom view, in draw 3 circles. how pass "colorview" argument? other man added of views ib (not code). , how change frames or visibility of these circles? add variables them? thank you.
- (void)drawrect:(cgrect)rect { cgcontextref con = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(con, colorofview.cgcolor); cgcontextfillellipseinrect(con, cgrectmake(0,10,85,85)); cgcontextsetfillcolorwithcolor(con, [uicolor clearcolor].cgcolor); cgcontextsetblendmode(con, kcgblendmodeclear); // erase cgcontextfillellipseinrect(con, cgrectmake(62, -1, 35, 35)); cgcontextsetfillcolorwithcolor(con, colorofview.cgcolor); cgcontextsetblendmode(con, kcgblendmodenormal); cgcontextfillellipseinrect(con, cgrectmake(65,0,30,30)); } now update color use other method:
- (void)setcustomtitle:(nsstring *)title andicon:(nsstring *)iconname andcircle:(uicolor *)color { self.titlelabel.text = title; self.iconimage.image = [uiimage imagenamed:iconname]; colorofview = color; self.circleview.backgroundcolor = color; [self setneedsdisplay]; }
you should create property color:
@property (nonatomic, strong) uicolor *colorofview; and change colorofview = color self.colorofview = color
and change cgcontextsetfillcolorwithcolor(con, colorofview.cgcolor); cgcontextsetfillcolorwithcolor(con, self.colorofview.cgcolor);
Comments
Post a Comment