2013年4月26日星期五
2013年4月23日星期二
iOS Animation 001
Animation is Easy, today We learning basic Animation use UIImageView(just like play film).
First need prepare a set of image frames, you can use PhotoShop or any other image edit tool do this.
Second Open Xcode , setup a project from "Single view Application" template.
Three some type
2013年1月15日星期二
UIView Animation with block
UIViewAnimationWithBlocks us block,animation finished no longer needed write callback method,it's more beautiful than old style.
- (void)setSelectedVeg:(id)sender
{
[selectedVegetableIcon setAlpha:0.0];
[UIView animateWithDuration:0.4
animations: ^{
float angle = [self spinnerAngleForVegetable:sender];
[vegetableSpinner setTransform:CGAffineTransformMakeRotation(angle)];
}
completion:^(BOOL finished) {
[selectedVegetableIcon setAlpha:1.0];
}];
}
code came from WWDC2010 iPlant PlantCareViem.m
old UIViewAnimation style Animation
- (void)setSelectedVeg:(id)sender
{
[selectedVegetableIcon setAlpha:0.0];
[UIView beginAnimations:@"setSelectedVeg" context:nil];
float angle = [self spinnerAngleForVegetable:sender];
[vegetableSpinner setTransform:CGAffineTransformMakeRotation(angle)];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(done)];
[UIView commitAnimations];
}
-(void)done
{
[selectedVegetableIcon setAlpha:1.0];
}
this article was written by me in 2010 on my Chinese blog.
[Tips] Show Circle in iOS app
show circle in iOS, in my old app https://itunes.apple.com/cn/app/jie-zhong-ri-ji/id513220773?mt=8
first get baby icon,and add a circle crop,after that ,Superposition it with background image
Iike this:
code
double radians (double degrees) {return degrees * M_PI/180;}-(UIImage*)createIconWithImage:(UIImage*)src{UIImage *circle=[UIImage imageNamed:@"Face@2x.png"];CGFloat width=circle.size.width;CGFloat height=circle.size.height;CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedFirst);CGContextDrawImage(context, CGRectMake(0, 0, width, height), circle.CGImage);if (src.imageOrientation == UIImageOrientationLeft) {CGContextRotateCTM (context, radians(90));CGContextTranslateCTM (context, 0, -height);} else if (src.imageOrientation == UIImageOrientationRight||src.imageOrientation == UIImageOrientationRightMirrored) {CGContextRotateCTM (context, radians(-90));CGContextTranslateCTM (context, -width, 0);} else if (src.imageOrientation == UIImageOrientationUp) {// NOTHING} else if (src.imageOrientation == UIImageOrientationDown) {CGContextTranslateCTM (context, width, height);CGContextRotateCTM (context, radians(-180.));}CGContextBeginPath(context);CGContextTranslateCTM (context, 4, 4);CGRect rect = CGRectMake(0, 0, width-12, height-12);CGContextAddEllipseInRect(context, rect);CGContextClosePath(context);CGContextClip(context);CGContextDrawImage(context, rect , src.CGImage);CGImageRef imageMasked = CGBitmapContextCreateImage(context);CGContextRelease(context);CGColorSpaceRelease(colorSpace);UIImage *image = [UIImage imageWithCGImage:imageMasked];CGImageRelease(imageMasked);return image;}
Apple CALayer Class Reference
订阅:
博文 (Atom)



