We apologize for the untimely interruption
We have been busy bees and have had no time for hackery.
In the meantime, here are some samples to play with.
We have been busy bees and have had no time for hackery.
In the meantime, here are some samples to play with.
CGContextRef context = CGBitmapContextCreate(…);
UIPushContext(context);
UITextLabel *textLabel = [[[UITextLabel alloc] initWithFrame:CGContextGetClipBoundingBox(context)] autorelease];
[textLabel setText:@”Hello world!”];
[textLabel setCentersHorizontally:YES];
[textLabel drawContentsInRect:[textLabel bounds]];
UIPopContext(context);
@implementation SlowFlipView
// Combine something old…
- (void)flipSlowly;
{
// enable perspective transforms
LKTransform sublayerTransform = LKTransformIdentity;
sublayerTransform.m34 = 1.0 / -420.0;
[[[self superview] _layer] setSublayerTransform:sublayerTransform];
[[self _layer] setTransform:LKTransformMakeRotation(M_PI, 0, -1, 0)];
}
// with something new…
- (id)actionForLayer:(LKLayer *)layer forKey:(NSString *)key;
{
if ([key isEqualToString:@”transform”]) {
LKBasicAnimation *flipAnimation = [LKBasicAnimation animationWithKeyPath:key];
[flipAnimation setTimingFunction:[LKTimingFunction functionWithName:@”easeInEaseOut”]];
[flipAnimation setDuration:5.0]; // take yr time there, partner
return flipAnimation;
} else
return [super actionForLayer:layer forKey:key];
}
@end
In a UITable subclass:
- (int)swipe:(int)num withEvent:(GSEventRef)event;
{
if (num == kUIViewSwipeRight)
[self handleSwipeRight];
// knowing the bounds of the swipe might be useful…
CGRect rect = (GSEventGetLocationInWindow(event));
NSLog(@”origin: (%f, %f) size: (%f, %f)”, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
}
- (void)buttonPressed
{
NSLog(@”Take action when a user finishes pressing a button, not when they start…”);
}
…
button = [[[UIPushButton alloc] initWithFrame:CGRectMake(…)] autorelease];
[button addTarget:self action:@selector(buttonPressed) forEvents:kUIControlEventMouseUpInside];
[button setShowPressFeedback:YES];
[button setEnabled:YES];
[view addSubview:button];
In your UIApplication instance:
[self openURL:[NSURL URLWithString:@”http://goatse.cx”]];
#import <GraphicsServices/GraphicsServices.h>
#import <UIKit/UIKit.h>
textLabel = [[UITextLabel alloc] initWithFrame:…];
GSFontRef font = GSFontCreateWithName(“Marker Felt”, kGSFontTraitBold, 18.0f);
[textLabel setFont:font];
CFRelease(font);
Wrap your messages to a UIView in +beginAnimations: and +endAnimations to automatically animate to the new state.
#import <UIKit/UIKit.h>
UIView *view = …
[UIView beginAnimations:nil];
[UIView setAnimationCurve:kUIAnimationCurveEaseInEaseOut];
[UIView setAnimationDuration:2.0];
// animate to the new frame in 2 seconds
[view setFrame:CGRectMake(0, 0, 100, 100)];
[UIView endAnimations];
There’s no MallocDebug or other leak checking tools, so make sure you’re not becoming a pig with:
# while true; do ps -xo vsz,rsz,pagein,pmem,command | grep MyAwesomePhoneApp | grep -v grep; echo “—-“; sleep 10; done
If you don’t watch it, Springboard will shut you down at about 64 MB.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface UIView (Color)
+ (CGColorRef)colorWithRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha;
@end
@implementation UIView (Color)
+ (CGColorRef)colorWithRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha;
{
float rgba[4] = {red, green, blue, alpha};
CGColorSpaceRef rgbColorSpace = (CGColorSpaceRef)[(id)CGColorSpaceCreateDeviceRGB() autorelease];
CGColorRef color = (CGColorRef)[(id)CGColorCreate(rgbColorSpace, rgba) autorelease];
return color;
}
@end
Don’t assume that the size of the screen is 320x480 (who’s to say that the next version of the iPhone won’t have a 480x640 screen?) Also the status bar can be more than 20 pixels high (like during a phone call.)
Do this:
CGRect contentRect = [UIHardware fullScreenApplicationContentRect];
UINavigationBar *navigationBar = [[[UINavigationBar alloc] initWithFrame:CGRectMake(contentRect.origin.x, contentRect.origin.y, contentRect.size.width, 44.0f)] autorelease];
UITextView *textView = [[[UITextView alloc] initWithFrame:CGRectMake(contentRect.origin.x, 44.0f, contentRect.size.width, contentRect.size.height - 44.0f)] autorelease];