core-graphics

CGContextShowText is rendering upside down text (mirror image)

你。 提交于 2020-01-02 05:36:06
问题 Without my doing anything to request upside down text, CGContextShowText is drawing it in that fashion. It is a mirror image vertically of what it should be. float font_size = 19.; CGContextSelectFont (context, "Helvetica", font_size, kCGEncodingMacRoman); CGContextSetTextDrawingMode (context, kCGTextFill); CGContextSetRGBStrokeColor (context, 255, 0, 0, 0); CGContextSetRGBFillColor (context, 255, 0, 0, 0); CGContextSetTextPosition (context, x, y); CGContextShowText (context, cstring, strlen

Is it possible to make UILabel with non-English characters green when Color Blended Layer is enabled?

老子叫甜甜 提交于 2020-01-02 03:37:13
问题 I have a table view with custom cells and I try to optimize it by making all subviews inside the cells in green color when Color Blended Layer is checked in the simulator. When the background of an UILabel in the cell is set to white: let title = UILabel() contentView.addSubview(title) title.background = UIColor.whiteColor() title.text = "Hi, how are you?" This UILabel subview will become green color in the simulator, which is good. However, if I change the text to some Chinese: title.text =

Get screen resolution programmatically in OS X

自古美人都是妖i 提交于 2020-01-02 01:30:09
问题 I'd like to launch a fullscreen 3D C++ application in native resolution on mac. How can I retrieve the native screen resolution ? 回答1: If you don't wish to use Objective C, get the display ID that you wish to display on (using e.g. CGMainDisplayID), then use CGDisplayPixelsWide and CGDisplayPixelsHigh to get the screen width and height, in pixels. See "Getting Information About Displays" for how to get other display information. If you're willing to use a bit of Objective-C, simply use [

Core Graphics Line drawing and deleting on touch

孤人 提交于 2020-01-02 00:32:27
问题 I am writing an iPhone application somewhat like pick up sticks app on appstore. I have already done with drawing multiple lines and displaying it using CoreGraphics. But now I am stuck with how to delete the line when the user taps on it. I have searched on Google a lot but didn't find anything related. I have seen this post of yours at some other place and this has really helped me out. but the problem is that if i have a stick and then another stick on top of it. when i click on the stick

How to move image in circle swift

試著忘記壹切 提交于 2020-01-01 18:18:55
问题 Can anybody explain to me how I can create the path of circle and move an image around it. What I need: let circlePath = UIBezierPath(arcCenter: CGPoint(x: 100,y: 100), radius: CGFloat(20), startAngle: CGFloat(0), endAngle:CGFloat(M_PI * 2), clockwise: true) I discovered how do the path of circle, but the rest I don't know to do. I'm new to iOS development. And, I need this action begin when I open the page. 回答1: Check this code, the objectToMove is an UIView from storyBoard to test, here I

iPhone/iPad draw pdf like iBooks?

这一生的挚爱 提交于 2020-01-01 18:05:10
问题 Does anyone know how to use core graphics to draw a pdf like in iBooks. I can already draw a pdf page using core graphics but was curious how iBooks shows a lower quality view of each page so it loads fast and then when you stay on a page longer it renders it a full quality. This makes it able to open the pdf without having to make the user wait like most magazine apps you see on ipad. Any ideas would help! 回答1: Apple have some "ZoomingPDFViewer" sample code: http://developer.apple.com

Adding a QuadCurve to UIBezierPath

ぃ、小莉子 提交于 2020-01-01 17:05:48
问题 I am doing a drawing app and I am trying to smooth the line which I draw with finger.For this purpose I am using "quadCurveToPoint" function. But, I am not getting it right. Below is my code: - (void) drawRect:(CGRect)rect { [path stroke]; } - (id) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) self.multipleTouchEnabled = NO; path = [UIBezierPath bezierPath]; path.lineWidth = IS_IPAD? 2.0f : 1.0f; return self; } - (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent

Animate a UIView's CoreGraphics/drawRect content

有些话、适合烂在心里 提交于 2020-01-01 15:47:52
问题 Is it possible to animate a UIView 's CoreGraphics content? Say I have a UIView subclass called MyView that implements the drawRect: method like so: - (void) drawRect: (CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(c, someColor); CGContextSetLineWidth(c, someWidth); CGContextMoveToPoint(c, leftOfMyUIView, topOfMyUIView); CGContextAddLineToPoint(c, leftOfMyUIView, bottomOfMyUIView); CGContextStrokePath(c); } In other words - it draws a vertical

EXC_BAD_ACCES drawing shadow

非 Y 不嫁゛ 提交于 2020-01-01 15:32:11
问题 I am trying to add a shadow to my UIView, but in my drawRect method I get an EXC_BAD_ACCESS. (I am using ARC) -(void) drawRect:(CGRect)rect { CGColorRef lightColor = [UIColor colorWithRed:105.0f/255.0f green:179.0f/255.0f blue:216.0f/255.0f alpha:0.8].CGColor; CGColorRef shadowColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.4].CGColor; CGContextRef context = UIGraphicsGetCurrentContext(); // Draw shadow CGContextSaveGState(context); CGContextSetShadowWithColor(context, CGSizeMake

CIFilter not working properly, returns null image

最后都变了- 提交于 2020-01-01 14:35:38
问题 Hey all i've been using some filters. Not all of them seem to work normally like say for example CISepiaTone and CIHueAdjust. recently i tried CIGLoom filter and it returns a null image. -(UIImage*)getGloom:(UIImage*)anImage{ CGImageRef cgimage = anImage.CGImage; CIImage *cimage = [CIImage imageWithCGImage:cgimage]; CIFilter *filter = [CIFilter filterWithName:@"CIGloom"]; [filter setDefaults]; [filter setValue: cimage forKey: @"inputImage"]; [filter setValue: [NSNumber numberWithFloat: 25]