Viewを拡大するエフェクトに関してのメモ
ポイント
・CGAffineTransformMakeScale
十秒かけて、Viewの大きさを5倍にするようなサンプルコード
[ EffectKun.h ]
@interface EffectKun : NSObject
+ (void)changeSize:(float)size view:(UIView*)view;
@end
[ EffectKun.m ]
@implementation EffectKun
+ (void)changeSize:(float)size view:(UIView*)view
{
[UIView beginAnimations:nil context:nil];
// 十秒間で
[UIView setAnimationDuration:10];
// 指定のサイズに縦横を拡大
view.transform = CGAffineTransformMakeScale(size, size);
[UIView commitAnimations];
}
@end
[ ViewController.m ]
#import “ViewController.h”
#import “EffectKun.h”
@interface ViewController ()
@end
@implementation ViewController
– (void)viewDidLoad
{
[super viewDidLoad];
CGRect rect = CGRectMake(50, 50, 50, 50);
// 拡大する View
UIView *big = [[UIView alloc] initWithFrame:rect];
big.backgroundColor = [UIColor redColor];
[self.view addSubview:big];
[EffectKun changeSize:2 view:big];
// 比較用
UIView *o = [[UIView alloc] initWithFrame:rect];
o.backgroundColor = [UIColor greenColor];
[self.view addSubview:o];
}
@end