User Code List
All my code
---Android
------Sending SMS using Intents
------Send email attachment
------read file from sdcard
------get size of screen
------Accelerometer in Android OS 2.x and deprecated API
------Getting Animation Drawables to actually Animate
------hide the status bar and title bar
------Email, send intent
------wifi scanner
---------New Snippet
------scrollable tabhost
------bluring windows when dialog shows up
------Animated activity transition, diagonal slide
------simple way to scale image
------monitor outgoing phone call
------add directory in sdcard
------EditTextPreference only numbers
------MapView, LongPress, GestureDetector, OnTouchListener
------Preference Screen with custom views
------write and read data from file
------background without stretching
------System setting, change and write_settings
------Creating Persistent AlertDialog for on Orientation Change
------print from Android application
------Screen in landscape mode
------add contact photo to your list
------Distance calculation between 2 Geopoint by Haversine formula
---Iphone
------get iphone orientation
------generate pdf from iphone
------new thread autorelease pool
------determine firmware version
------turn page animation
------load resource file to webview
------call javascript in Objective-C code
------call objective-C code from Javascript
------Disable Webview selection flash
------Disable the action popup
------Disable webview zoom effect
---Utilities
------recursive remove .svn directory
New Snippet
 
 
turn page animation
 

- (IBAction) openButton:(id)sender {

UIButton *button = (UIButton *)sender;

// disable the button so it’s not pressed again during the animation

((UIView *)sender).userInteractionEnabled = NO;

// Set the CALayer anchorPoint to the left edge and

// translate the button to account for the new

// anchorPoint. In case you want to reuse the animation

// for this button, we only do the translation and

// anchor point setting once.

if (button.layer.anchorPoint.x != 0.0f)

{

button.layer.anchorPoint = CGPointMake(0.0f, 0.5f);

button.center = CGPointMake(button.center.x – button.bounds.size.width/2.0f, button.center.y);

}

// create an animation to hold the page turning

CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];

transformAnimation.removedOnCompletion = NO;

transformAnimation.duration = 2.0f;

transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

// start the animation from the current state

transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];

// this is the basic rotation by 90 degree along the y-axis

CATransform3D endTransform = CATransform3DMakeRotation(3.141f/2.0f, 0.0f, -1.0f, 0.0f);

// these values control the 3D projection outlook

endTransform.m34 = 0.001f;

endTransform.m14 = -0.0015f;

transformAnimation.toValue = [NSValue valueWithCATransform3D:endTransform];

// Create an animation group to hold the rotation

CAAnimationGroup *theGroup = [CAAnimationGroup animation];

// Set self as the delegate to receive notification when the animation finishes

theGroup.delegate = self; theGroup.duration = 2.0;

// CAAnimation-objects support arbitrary Key-Value pairs, we add the UIView tag

// to identify the animation later when it finishes

[theGroup setValue:[NSNumber numberWithInt:button.tag] forKey:@”buttonTag”];

// Here you could add other animations to the array

theGroup.animations = [NSArray arrayWithObjects:transformAnimation, nil]; theGroup.removedOnCompletion = NO;

// Add the animation group to the layer

[button.layer addAnimation:theGroup forKey:@"flipButtonOpen"];

}

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {

// Get the tag from the animation, we use it to find the

// animated UIView

NSNumber *tag = [theAnimation valueForKey:@"buttonTag"];

// Find the UIView with the tag and do what you want

for (UIView *subview in contents.subviews) {

if ([subview isKindOfClass:[UIButton class]]) {

if (subview.tag == [tag intValue])

subview.hidden = YES;

}

}

}

 
Sub-Article List