quartz-2d

draw pie chart using iOS quartz 2D

狂风中的少年 提交于 2020-02-24 11:23:25
问题 I am looking for a tutorial where I can draw pie chart programmatically using Core Graphics or Quartz 2D in iOS. I want to understand how can we draw the PIE Chart which is gradient and having multi-color filled slices in it. Note: Not looking for Coreplot framework. Please share me some links regarding the same. 回答1: I have used "XYPieChart" library in my so many apps and it's very easy to modify. Available on github. Link is given below: https://github.com/xyfeng/XYPieChart Still needs any

Drawing NSString to UIImage

自闭症网瘾萝莉.ら 提交于 2020-01-30 08:17:05
问题 I have a NSString object. I want to write it to existing UIImage object. UIImage object already has some image associate with it. I want to write string to same image. How do i achieve it? 回答1: EDIT: Following are basic step to achieve to edit an UIImage and write text on it. Get CGImage from UIImage. Render CGImage On context. Render Text you want to write on the same context. Get Bitmap of context and make CGImage out of that. Get UIImage from CGImage.... It would be much easier to show

How to set a gradient border on UIView?

拟墨画扇 提交于 2020-01-20 19:42:49
问题 It's very easy to put a simple border on a UIView . You simply link to QuartzCore , import it, and use: self.view.layer.borderColor = [UIColor redColor].CGColor; self.view.layer.borderWidth = 2.0f; My question is... Is there a way to make this border use a gradient. I know how to apply a gradient mask to the entire view, but not just to its border. I'm assuming this could involve a custom view and CoreGraphics drawing inside drawRect: , but I'm not sure where to start. 回答1: I'm not entirely

How to display text using Quartz on the iPhone?

可紊 提交于 2020-01-12 05:21:12
问题 I've been trying to display text using a Quartz context, but no matter what I've tried I simply haven't had luck getting the text to display (I'm able to display all sorts of other Quartz objects though). Anybody knows what I might be doing wrong? example: -(void)drawRect:(CGRect)rect { // Drawing code CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSelectFont(context, "Arial", 24, kCGEncodingFontSpecific); CGContextSetTextPosition(context,80,80); CGContextShowText(context,

All colors work except whiteColor

烂漫一生 提交于 2020-01-05 05:52:02
问题 const CGFloat *color = CGColorGetComponents([[UIColor whiteColor] CGColor]); CGContextSetFillColor(context, color); I have black background. While working this above code not sure whats wrong most of the colors work like redColor, purpleColor, greenColor, yellowColor but whiteColor, grayColor does not work. when i use whiteColor screen looks empty. 回答1: whiteColor and greyColor have colorspace different from redColor , purpleColor etc (I guess gray and rgb correspondently) and

All colors work except whiteColor

只谈情不闲聊 提交于 2020-01-05 05:51:25
问题 const CGFloat *color = CGColorGetComponents([[UIColor whiteColor] CGColor]); CGContextSetFillColor(context, color); I have black background. While working this above code not sure whats wrong most of the colors work like redColor, purpleColor, greenColor, yellowColor but whiteColor, grayColor does not work. when i use whiteColor screen looks empty. 回答1: whiteColor and greyColor have colorspace different from redColor , purpleColor etc (I guess gray and rgb correspondently) and

“Beveled” Shapes in Quartz 2D

寵の児 提交于 2020-01-04 09:13:50
问题 I'm familiar with some of the basics of Quartz 2D drawing, like drawing basic shapes and gradients and so on, but I'm not sure how to draw a shape with a "beveled" look, like this: beveled circle http://www.shaggyfrog.com/junk/beveled-circle.jpg Essentially we've got a shine on one corner, and maybe some shading in the opposite corner. I think -- I didn't make this image, although I'd like to be able to approximate it. Any ideas? This is on the iPhone, and I'd like to use built-in frameworks

Mac OS X: Drawing into an offscreen NSGraphicsContext using CGContextRef C functions has no effect. Why?

烂漫一生 提交于 2019-12-30 01:26:25
问题 Mac OS X 10.7.4 I am drawing into an offscreen graphics context created via +[NSGraphicsContext graphicsContextWithBitmapImageRep:] . When I draw into this graphics context using the NSBezierPath class , everything works as expected. However, when I draw into this graphics context using the CGContextRef C functions , I see no results of my drawing. Nothing works. For reasons I won't get into, I really need to draw using the CGContextRef functions (rather than the Cocoa NSBezierPath class). My