Tag: core graphics

Rounded Corners only on Top of a UIView

Hi i am searching a clean solution without overwriting drawRect or stuff like that to create a UIView with Rounded corners on the Top of the View. My main problem here is to create variable solution if the view is getting resized or something like that. Is there a clean solution? Apple is this doing […]

How do I add a gradient to the text of a UILabel, but not the background?

hey, I want to be able to have a gradient fill on the text in a UILabel I know about CGGradient but i dont know how i would use it on a UILabel’s text i found this on google but i cant manage to get it to work http://silverity.livejournal.com/26436.html

How to change a particular color in an image?

My question is if I have a Lion image just I want to change the color of the lion alone not the background color. For that I referred this SO question but it turns the color of whole image. Moreover the image is not looking great. I need the color change like photoshop. whether it […]

invalid context 0x0 under iOS 7.0 and system degradation

I’ve read as many search results I could find on this dreaded problem, unfortunatelly, each one seems to focus on a specific function call. My problem is that I get the same error from multiple functions, which I am guessing are being called back from functions that I use. To make matters worse, the actual […]

iPhone cannot create CGBitmapContext

I have a problem with creating a CGBitmapContext. CGContextRef bitmapContext = CGBitmapContextCreate(nil, imageSize.width, imageSize.height, 8, imageSize.width * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst) When I run my application normally it works. But when I run it in my ‘Test application’ (a running app that will perform my tests) the context is logged as (null) and I get the […]

How do I draw on an image in Swift?

I need to be able to programmatically draw on an image, and save that image for later use. Say, draw a line on specific x and y coordinates on the image, save the image, and display it onto a simple view controller. How would I go about doing this in Swift? (Preferably Swift 2, I […]

How do you load a local jpeg or png image file into an iPhone app?

Or I should ask why is it so difficult for me? The answer is probably that I’m new to iPhone development and I’m trying to ditch my old methods and step into the new platform of the future. From start to finish, I have a few questions about this process… If I create a .png […]

Front most window using CGWindowListCopyWindowInfo

In the documentation, it says that list of windows returned by this method: CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); will return windows in order from front to back. But it doesn’t…The front most window should be test, but here’s the out of this array: 2011-03-12 18:18:14.221 test[982:a0f] ( { kCGWindowAlpha = 1; kCGWindowBounds = { Height […]

CTFramesetterSuggestFrameSizeWithConstraints sometimes returns incorrect size?

In the code below, CTFramesetterSuggestFrameSizeWithConstraints sometimes returns a CGSize with a height that is not big enough to contain all the text that is being passed into it. I did look at this answer. But in my case the width of the text box needs to be constant. Is there any other/better way to figure […]

CGContextSaveGState: invalid context 0x0 Error only on device

Update: I am using XCode 7 Beta with Swift 2.0 When I try to run my app on an iPhone I get these 3 errors: <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please […]