This section will continue from where we left off last week. We'll work with solid fills, gradient fills, and image and pattern fills. Open up the project from last week, and let's get started. Navigate to CustomView.m Single Color Fills In the last section we filled our paths with solid fill colors. In those cases, we started with a color defined with UIColor. In some cases, however, you may want more control. Quartz's underlying color structure is represented using a data type called CGColorRef (sometimes abbreviated to CGColor). You can create a UIColor with a CGColor and vice versa. UIColor has the +colorWithCGColor: method, and instances of UIColor have a .CGColor property. For example, to create a CGColor that represents a bright aqua color, we could use this code: [UIColor colorWithRed:0 green:0.5 blue:1].CGColor; To fill a rectangle with this color, we could use the following code: CGContextSetFillColorWithColor(context, [UIColor colorWithRed:0 green:0.5 blue:1 alpha:1].CGColor); CGContextFillRect(context, CGRectMake(20, 30, 80, 100)); Remember the state-based nature of Quartz—You set a color, or a certain style, then use it.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
Design Patterns,Series,Tutorial,Gradient,Images,iOS,Quartz
Design Patterns,Series,Tutorial,Gradient,Images,iOS,Quartz
No comments:
Post a Comment