2013年1月17日星期四
2013年1月16日星期三
introduce Multiple Layer Animation
Apple system have many methods do Animation:
1 View base, I have introduce in uiview-animation-with-block
2 ImageView base, frame animation like play film
3 Core Animation
Today, I share some code in my work:
1 View base, I have introduce in uiview-animation-with-block
2 ImageView base, frame animation like play film
3 Core Animation
Today, I share some code in my work:
- (IBAction)doAnimation:(id)sender {
int i;
for (i=0 ; i< [_leafs count] ;i++) {
UIView *tmpBarItem = [_leafs objectAtIndex:i ];
[tmpBarItem.layer addAnimation:[self leafsAnimation:CGPointMake(tmpBarItem.center.x,tmpBarItem.center.y-tmpBarItem.frame.size.height/2)
beginTime:0
Animationname:[NSString stringWithFormat:@"%d",i ]] forKey:@"position"];
tmpBarItem.layer.anchorPoint= CGPointMake(0.5, 0);
tmpBarItem.center = CGPointMake(tmpBarItem.center.x-length,tmpBarItem.center.y-tmpBarItem.frame.size.height/2);
}
}
-(CAAnimation*)leafsAnimation:(CGPoint)fromPoint beginTime:(CGFloat)abeginTime Animationname:(NSString *)name
{
CAKeyframeAnimation *move0 = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef thePath0 = CGPathCreateMutable();
CGPathMoveToPoint(thePath0, NULL, fromPoint.x, fromPoint.y);
CGPathAddLineToPoint(thePath0, NULL, fromPoint.x-length, fromPoint.y);
float t1=1.2;
float t2= 1.0;
move0.duration=t1;
move0.path = thePath0;
CGPathRelease(thePath0);
//CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *move = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
move.removedOnCompletion = YES;
move.beginTime = t1;
move.duration = t2;
move.values = [NSArray arrayWithObjects:
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(-10)))],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(20)))],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(-(20/2+5))))],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(10)))],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(-(10/2+2.5))))],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(5)))],
[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(CGAffineTransformMakeRotation(radians(0)))],nil];
move.keyTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.2],
[NSNumber numberWithFloat:0.4],
[NSNumber numberWithFloat:0.6],
[NSNumber numberWithFloat:0.8],
[NSNumber numberWithFloat:1],nil];
CAAnimationGroup *group = [CAAnimationGroup animation];
group.duration = t1+t2;
group.delegate = self;
[group setValue:name forKey:@"name"];
//move.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
group.animations = [NSArray arrayWithObjects:move0,move,nil];
return group;
}
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
NSLog(@"%@",[theAnimation valueForKey:@"name"]);
}
demo ios application project source code https://github.com/yarshure/yarshure/blob/master/FlyLeafDemo.zip
I upload a video ,you can watch it on youtube.
[Tips]how to find MAS downloading file url
some times Mac app store application download Mac OS X update package very slow, so I write this tips.
First use MAS app start downloading
second open terminal:
rMBP:~ yarshure$ lsof |grep apple.com
WebProces 304 yarshure 33u REG 1,3 12288 756415 /Users/yarshure/Library/Safari/LocalStorage/http_support.apple.com_0.localstorage
App\x20St 5400 yarshure 11w REG 1,3 117339677 11229520 /private/var/folders/bk/j1vyw0wd1nx8lldrzc4z8z300000gn/C/com.apple.SoftwareUpdate/swcdn.apple.com/content/downloads/53/57/041-9585/m24b4n13ngu3s79fguytcmmzsojk1sb2o2/OSXUpd10.8.3Seed.pkg
apple update package downloading server is swcdn.apple.com, so we found the url is:
http://swcdn.apple.com/content/downloads/53/57/041-9585/m24b4n13ngu3s79fguytcmmzsojk1sb2o2/OSXUpd10.8.3Seed.pkg.
aha,very easy! I have used this method several times download Mac OS X 10.8.3 Beta update package.
My family second live house
My family live in this house between Aug 1995 and Oct 2005.
This photo was taken in Sep 2010, half year before my mother dead.
Before I go to high school, my father sell big one house in countryside, and
we move to the little town(双阳镇/double sun).
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
2013年1月13日星期日
Retina What?
I have used Retina MacBook Pro for four months, retina is very comfort for Reading.
Last week I Sell My old MacBook Pro 17' MC227, I purchase it spend 16300¥, after purchased, I add one intel X25-M 80G SSD, 4Gx2 1066 Memory, and 256G SSD. totally about 3000$.
In Mar 2011,I buy Carriers contract's iPhone4 from China Unicom.
In Oct 2011,I buy contract free iPhone 4s from Apple Canada online store, my fiend who live in Toronto help me Received Goods, and send to China.
In May 2012,I get retina version iPad, +Leask Huang buy it from HK.
In Nov 2012,I get iPhone5 HK version from my provider, before it on my hand, it have been actived.
anyway, it is a consumer electronic。
I use China Telecom sim card because it bind my fiber optic broadband,it only cost me 1$.
In Nov 2012, My friend +Nan Chen help me buy on iPad 4th in Canada, the month Human flesh Express on my hand.
iPad mini release one week, I have chance to use it. It's light more than 9.7' iPad, but mot comfort for Reading.
This year ,I guess apple will release retina version iPad mini, and more will Quad-Core Arm iDevice?
Last week I Sell My old MacBook Pro 17' MC227, I purchase it spend 16300¥, after purchased, I add one intel X25-M 80G SSD, 4Gx2 1066 Memory, and 256G SSD. totally about 3000$.
In Mar 2011,I buy Carriers contract's iPhone4 from China Unicom.
In Oct 2011,I buy contract free iPhone 4s from Apple Canada online store, my fiend who live in Toronto help me Received Goods, and send to China.
In May 2012,I get retina version iPad, +Leask Huang buy it from HK.
In Nov 2012,I get iPhone5 HK version from my provider, before it on my hand, it have been actived.
anyway, it is a consumer electronic。
I use China Telecom sim card because it bind my fiber optic broadband,it only cost me 1$.
In Nov 2012, My friend +Nan Chen help me buy on iPad 4th in Canada, the month Human flesh Express on my hand.
iPad mini release one week, I have chance to use it. It's light more than 9.7' iPad, but mot comfort for Reading.
This year ,I guess apple will release retina version iPad mini, and more will Quad-Core Arm iDevice?
订阅:
博文 (Atom)


