PowenKo, iOS Tutorial 88-1 , Quartz, circle with background image

September 8, 2011   ·   0 Comments

//
//  IGraph.m
//  Tutorial_Quartz_Circle
//
//  Created by JON MOODY on 9/8/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "IGraph.h"

@implementation IGraph

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
    }
    
    return self;
}
- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        // Initialization code
    }
    backgroundImage = [UIImage imageNamed:@"apple.jpg"];
    m_circle=false;
    return self;
}

- (void)drawRect:(CGRect)rect {
	CGContextRef	context = UIGraphicsGetCurrentContext();	
	CGPoint drawingTargetPoint = CGPointMake(0,0);
	[backgroundImage drawAtPoint:drawingTargetPoint];	
    
 	
    if(m_circle){
      
        CGGradientRef gradient;
        CGColorSpaceRef colorSpace;
        CGFloat locations[] = {0.0,1.0};
        CGFloat components[] = { 0.5,1.0,1.0,1.0, 0.25,0.5,0.5,1.0 };
        colorSpace = CGColorSpaceCreateDeviceRGB();
       // colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
        gradient = CGGradientCreateWithColorComponents(colorSpace,components,locations,
                                                       sizeof(locations)/sizeof(CGFloat));
        CGPoint start = {70.0,130.0}, end = {100.0,100.0};
        CGFloat startRadius = 0.0, endRadius = 90.0;
        CGContextDrawRadialGradient(context,gradient,start,startRadius,end,endRadius,0);
        CGGradientRelease(gradient);
        CGColorSpaceRelease(colorSpace);
    }
}
- (void)circle{

    m_circle=true;
    [self setNeedsDisplay];
}
@end

#import <Foundation/Foundation.h>

@interface IGraph : UIView {
    
	UIImage* backgroundImage;
    Boolean m_circle;
}
-(void)circle;

@end

sample code:
Tutorial_Quartz_Circle

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