quartz-graphics

UIView with shadow

心已入冬 提交于 2019-12-20 12:36:22
问题 I'm trying to create a shadow around a simple UIView object which is added on top of a UIViewController's view. what's the most straight forward way of doing this? 回答1: First, be sure to import the Quartz Core library: #import <QuartzCore/QuartzCore.h> Next, add the following lines to set up the shadow's properties: someView.layer.shadowColor = [[UIColor blackColor] CGColor]; someView.layer.shadowOffset = CGSizeMake(10.0f,10.0f); someView.layer.shadowOpacity = .5f; someView.layer.shadowRadius

Beginner iphone question: drawing a rectangle. What am I doing wrong?

邮差的信 提交于 2019-12-20 09:55:22
问题 Trying to figure out what I'm doing wrong here. Have tried several things, but I never see that elusive rectangle on the screen. Right now, that's all I want to do -- just draw a single rectangle on the screen. I'm getting an "invalid context" on everything but the CGContextSetRGBFillColor(). Getting the context after that seems kinda wrong to me, but I'm not at home looking at the examples I was using last night. Have I messed up something else as well? I really would like to get at least

Using cornerRadius on a UIImageView in a UITableViewCell

无人久伴 提交于 2019-12-20 08:53:51
问题 I'm using a UIImageView for each of my UITableViewCells , as thumbnails. My code uses SDWebImage to asynchronously grab those images from my backend and load them in, and then caching them. This is working fine. My UIImageView is a 50x50 square, created in Interface Builder. Its background is opaque, white color (same as my UITableViewCell background color, for performance). However, I'd like to use smooth corners for better aesthetics. If I do this: UIImageView *itemImageView = (UIImageView

How to use CgLayer for optimal drawing

前提是你 提交于 2019-12-20 07:25:59
问题 I have created a simple drawing project,the code works fine, but I want to cache the drawing into CGlayer, because I read that its more efficient way in drawing . I have read through the documents, but not able to understand it properly. So friends, I request you to please help me in this regard. Below is my code, I want to know how to use CgLayer in this - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); if(myLayerRef == nil) { myLayerRef =

Quartz PDF API Causing Out of Memory Crashes

我的未来我决定 提交于 2019-12-20 03:29:10
问题 I'm having crashing issues using the Quartz PDF API for iOS. At the moment I am compiling with the SDK 4.0 GM Seed and running on my 3.2 iPad (I have tried using the 3.2 SDK with identical results). All the code I am using is based on the standard Apple Quartz documentation and from various sources around the internets. So I can't image I'm doing something drastically different or wrong. The code runs perfectly in the Simulator (all versions, it's a Universal app) and even while using the

Cocoa Touch - Adding texture with overlay view

可紊 提交于 2019-12-20 03:03:34
问题 I have a set of tiles as UIViews that have a programmable background color, and each one can be a different color. I want to add texture, like a side-lit bevel, to each one. Can this be done with an overlay view or by some other method? I'm looking for suggestions that don't require a custom image file for each case. 回答1: This may help someone, although this was pieced together from other topics on SO. To create a beveled tile image with an arbitrary color for normal and for retina display, I

Are most games on the IPhone done with OpenGL ES?

心已入冬 提交于 2019-12-19 19:51:41
问题 I was just wondering if most games on the iPhone are done in OpenGL ES as opposed to using Quartz and Core Animation. Are Quartz and Core Animation mostly used for just creating slick interfaces? Or if there is a point with games where OpenGL probably has to be used over using other tools? 回答1: For efficiency reasons OpenGL ES is you best choice for games, unless your writing a "simple" board game or card game (like Solitaire). In this case Core Animation would be a good fit. 回答2: You should

Comparing colors in Objective-C

断了今生、忘了曾经 提交于 2019-12-19 06:40:13
问题 I'm trying to determine if two colors are equivalent, using code written in Objective-C. I'm using this snippet of code to determine if the two colors are equivalent (currently for debugging purposes) NSLog(@"currentColor is %@", currentColor); NSLog(@"Adjacent Color is %@",[[buttonArray objectAtIndex:1] backgroundColor]); NSLog(@"%i",[[buttonArray objectAtIndex:1] backgroundColor]==currentColor); My console is showing 2009-10-20 00:27:10.814 colorGame[13588:207] currentColor is

Comparing colors in Objective-C

落爺英雄遲暮 提交于 2019-12-19 06:40:09
问题 I'm trying to determine if two colors are equivalent, using code written in Objective-C. I'm using this snippet of code to determine if the two colors are equivalent (currently for debugging purposes) NSLog(@"currentColor is %@", currentColor); NSLog(@"Adjacent Color is %@",[[buttonArray objectAtIndex:1] backgroundColor]); NSLog(@"%i",[[buttonArray objectAtIndex:1] backgroundColor]==currentColor); My console is showing 2009-10-20 00:27:10.814 colorGame[13588:207] currentColor is

Export CGPath as JPG or PNG

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-19 04:56:27
问题 Is it possible to take a path draw in an UIView with CGPath and export it as a PNG? 回答1: Assuming you want a UIImage, not a png file, you can do something like this: UIGraphicsBeginImageContext(size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0); CGContextSetLineWidth(context, 2.0); CGContextSetLineCap(context, kCGLineCapSquare); //DRAW YOUR PATH HERE CGContextStrokePath(context); myUIImage =