Graphics
iOS Developer Tips - Visitor Stats:
|
|
|
Converting Radians to Degrees and Degrees to Radians
In mathematics, a radian is often used as a standard unit of measure when expressing angles. For various methods in iOS classes that deal with angles and rotation, the parameters and return values are often in radians. My brain doesn’t think in radians, I visualize angles and rotations in degrees, hence the code in this [...]
Creating Background Patterns
Beyond custom images and solid colors, a nice effect for a background is to use a repeating pattern. The code example that follows shows just how easy this is. For this example, I started with the image below, a photo that I took in the Fall with my iPhone. I downloaded and cropped the image [...]
Drag an Image within the Bounds of Superview
This post demonstrates how to drag an image on screen, respecting the bounds of the images superview. The first step is to create a class that inherits from UIImageView, I’ll name the class ImageToDrag. There is only one instance variable in this class, currentPoint – a CGPoint structure which has an X and Y coordinate [...]
How to Crop an Image
This post shows an example of one way to crop an image. Let’s begin by looking at a screenshot of the original and cropped image on the iPhone simulator: As you can see, I am cropping a rectangle from the middle of the image on the top left. The code below shows how to accomplished [...]
Convert an Image (UIImage) to Grayscale
A trick you won’t need often, yet when the day arrives, you’ll have this up your sleeve – a quick method to convert a UIImage object to grayscale.
Resize/Scale of an Image – Take 2 – Coding a Thread Safe Approach
In the first post on image resizing, How to Resize/Scale an Image using an Objective-C Category, I wrote barebones approach to resizing an image. This works well for simple cases, however this approach is not thread safe as it uses the global current context. I attended a recent Apple Tech Talk and one of the [...]
Gotcha: Case Sensitive PNG Filename
Here’s one that will trip you up if you aren’t careful…look at this code: timerButton = [[UIButton alloc] initWithFrame:CGRectMake(104, 410, 50, 50)]; // Notice the filename "timer.png" [timerButton setBackgroundImage:[UIImage imageNamed:@"timer.png"] forState:UIControlStateNormal]; [timerButton addTarget:self action:@selector(buttonPressed:) forControlEvents: UIControlEventTouchUpInside]; [self.view addSubview:timerButton]; Simple enough, create a button, use the image timer.png for the normal state, and [...]
Resize/Scale of an Image – Take 1 – Using an Objective-C Category
Editor’s Note: Part 2 of this post Resize/Scale of an Image – Take 2 – Thread Safe Approach takes this idea to the next level, showing how to dynamically resize images using thread safe code. Given how common it is to scale an image within an application, it’s surprising (at least to me) that such [...]
Animated Gif – Animated Images – iPhone Style
Using animated gif and animated images with the iPhone SDK.
Creating iPhone Icons
I’ve been poking around for a decent tutorial on how to create icons for the iPhone. Specifically, I am looking for a walk through with either PhotoShop or FireWorks. The icon I have in mind is what will be shown on the home screen of the iPhone as well as on the App Store. The [...]






