PowenKo, iOS Tutorial 88-2 , Quartz, square with background image

September 8, 2011   ·   0 Comments


- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
	CGContextRef	context = UIGraphicsGetCurrentContext();	
    
 	
    if(m_square){
        
        CGContextSetRGBStrokeColor(context, 1.0, 1.0, 0.0, 1.0); // yellow line
        
        CGContextBeginPath(context);
        
        CGContextMoveToPoint(context, 50.0, 50.0); //start point
        CGContextAddLineToPoint(context, 250.0, 100.0);
        CGContextAddLineToPoint(context, 250.0, 350.0);
        CGContextAddLineToPoint(context, 50.0, 350.0); // end path
        
        CGContextClosePath(context); // close path
        
        CGContextSetLineWidth(context, 8.0); // this is set from now on until you explicitly change it
        
        CGContextStrokePath(context); // do actual stroking
        
        CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 0.5); // green color, half transparent
        CGContextFillRect(context, CGRectMake(20.0, 250.0, 128.0, 128.0)); // a square at the bottom left-hand corner
        
    }
}

 

sample code:

Tutorial_Quartz_Circle_Square

 

reference:

http://www.codeproject.com/KB/iPhone/iOSGetStarted01.aspx

 

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
iOS Tutorial9

Amazon

adsbygoogle

Recent Posts

Categories

Amazon