Sunday, 15 March 2015

objective c - Moving Rectangle in Quartz -



objective c - Moving Rectangle in Quartz -

i attempting larn basics of quartz , not understand why not work - should move reddish rectangle right when button pushed, bat @ momoent, not - "nslog(a"help"); seek figure out if button functioning - thanks

@implementation quartzview -(ibaction)moveright:(id)sender{ nslog(@"help"); lr += 50; } - (id)initwithframe:(nsrect)framerect { self = [super initwithframe:framerect]; if (self) { } homecoming self; } - (void)drawrect:(nsrect)dirtyrect { cgcontextref mycontext = [[nsgraphicscontext // 1 currentcontext] graphicsport]; // drawing code here. cgcontextsetrgbfillcolor (mycontext, 1, 0, 0, 1);// 3 cgcontextfillrect (mycontext, cgrectmake (lr, 0, 200, 100 )); [self setneedsdisplay:yes]; } @end

thanks!

you don't want phone call setneedsdisplay in drawrect; says, "now i've drawn view, create me again!"

you want phone call setneedsdisplay in action, update screen after moves rectangle.

objective-c xcode4.5 quartz-2d

No comments:

Post a Comment