ios - How to stop clipping of NSString drawAtPoint: withAttributes: in a UIView subclass -
how 1 utilize drawatpoint: withattributes within instance of uiview subclass text drawn on screen can seen outside of frame of uiview subclass instance? utilize of [self setclipstobounds:no] within subclass of uiview resulting in clipping of text along frame of view.
the uiview subclass using, wordview.m:
#import "wordview.h" @implementation wordview -(id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { [self setbackgroundcolor:[uicolor redcolor]]; [self setclipstobounds:no]; } homecoming self; } - (void)drawrect:(cgrect)rect { [@"hello world" drawatpoint:cgpointmake(0, 0) withattributes:@{ nsfontattributename: [uifont systemfontofsize:40], nsforegroundcolorattributename:[uicolor greencolor] }]; } @end
i creating wordview in viewwillappear stage of viewcontroller:
-(void)viewwillappear:(bool)animated { wordview *wordview = [[wordview alloc]initwithframe:cgrectmake(20, 20, 150, 40)]; [self.view addsubview:wordview]; }
ios objective-c uiview
No comments:
Post a Comment