Rectangle To Rectangle Collision Detection

- (BOOL) rect:(CGRect) rect collisionWithRect:(CGRect) rectTwo
{
	float rect_x1 = rect.origin.x;
	float rect_x2 = rect_x1+rect.size.width;
	
	float rect_y1 = rect.origin.y;
	float rect_y2 = rect_y1+rect.size.height;
	
	float rect2_x1 = rectTwo.origin.x;
	float rect2_x2 = rect2_x1+rectTwo.size.width;
	
	float rect2_y1 = rectTwo.origin.y;
	float rect2_y2 = rect2_y1+rectTwo.size.height;
	
	if((rect_x2 > rect2_x1 && rect_x1 < rect2_x2) &&(rect_y2 > rect2_y1 && rect_y1 < rect2_y2))
		return YES;
	
	return NO;
}

Thursday, March 4, 2010

Comparison Of XML Parsers For The iPhone SDK

Thursday, March 4, 2010

iPhone SDK Using Hex Values For UIColor

Here is a simple category to make using hex values for UIColor easier.

// UIColor+Hex.h

#import 

@interface UIColor (Hex)

+ (UIColor *) colorWithHex:(uint) hex;

@end
// UIColor+Hex.m

#import "UIColor+Hex.h"

@implementation UIColor (Hex)

+ (UIColor *) colorWithHex:(uint) hex
{
	int red, green, blue, alpha;
	
	blue = hex & 0x000000FF;
	green = ((hex & 0x0000FF00) >> 8);
	red = ((hex & 0x00FF0000) >> 16);
	alpha = ((hex & 0xFF000000) >> 24);
	
	return [UIColor colorWithRed:red/255.0f 
                               green:green/255.0f 
                               blue:blue/255.0f 
                               alpha:alpha/255.f];
}

@end
Wednesday, March 3, 2010

iPhone SDK UIAlertView With Activity Indicator

Looking for a quick and easy way to show an activity indicator? I found the easiest way was to subclass UIAlertView to make a reusable solution. Click read more for the code.

Wednesday, February 17, 2010 Read more …

Easy custom UITableView drawing

Monday, February 15, 2010