Why Are UIBarButtonItems Such a PITA

Ash Furrow wrote this up a while ago. Though old, it’s a classically well-written piece. Basically, UIBarButtonItem is a much more “OsX” style of UI class. Advertisements


One More Simple Thing I Struggle To Remember

Creating a UIImage from code. In this case a green background with a red X.

Add this to the snippets:

start a new context with a size and scale:

    UIGraphicsBeginImageContextWithOptions(imageSize, YES, 2.0);
    CGContextRef context = UIGraphicsGetCurrentContext();

Do the Core Graphics Work:

    [[UIColor greenColor] setFill];
    CGContextFillRect(context, CGRectMake(0, 0, imageSize.width, imageSize.height));
    CGFloat margin = 0.05*MAX(imageSize.width, imageSize.height);
    CGContextSetLineWidth(context, 6.0);
    CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
    CGContextSetLineCap(context, kCGLineCapRound);
    CGContextMoveToPoint(context, margin, margin);
    CGContextAddLineToPoint(context, imageSize.width - margin, imageSize.height - margin);
    CGContextMoveToPoint(context, imageSize.width - margin, margin);
    CGContextAddLineToPoint(context, margin, imageSize.height - margin);

Capture the image from the context and end the context:

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();


Looks Nice

Not only am I excited to register for WWDC lottery this year, I think that the site looks really good, and hope that they release whatever font this is for use in XCode. Advertisements