//
// SampleDay9ViewController.m
// SampleDay9
//
// Created by bit on 11. 5. 26..
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "SampleDay9ViewController.h"
// 아래 소스를 넣어 주어야 한다.. 자동완성 기능을 사용하기 위해서라도..
#import
@implementation SampleDay9ViewController
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = (UIButton *)[self.view viewWithTag:TAG_BUTTON];
[button addTarget:self action:@selector(animated:) forControlEvents:UIControlEventTouchUpInside];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
-(IBAction)animated:(id)sender {
NSLog(@"Clicked Button!!!");
UIView *theView = [self.view viewWithTag:TAG_VIEW];
// transaction 기능은 ?
// - 없어도 돌아 간다.
// - randering을 위해서...
// - 추가 설정이 가능하다...
// - 기본적인 설정을 받아서 사용할수 있다..
// Key-Value 코딩 설명
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:2.0f] forKey:kCATransactionAnimationDuration];
CABasicAnimation *shrinkAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
shrinkAnimation.delegate = self;
shrinkAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
shrinkAnimation.toValue = [NSNumber numberWithFloat:0.0f];
[theView.layer addAnimation:shrinkAnimation forKey:@"shrinkAnimation"];
//회전
CABasicAnimation* spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
spinAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
spinAnimation.toValue = [NSNumber numberWithFloat:M_PI];
[theView.layer addAnimation:spinAnimation forKey:@"spinAnimation"];
// fade out
CABasicAnimation* fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
fadeAnimation.toValue = [NSNumber numberWithFloat:0.0f];
[theView.layer addAnimation:fadeAnimation forKey:@"fadeAnimation"];
[CATransaction commit];
}
@end
댓글 없음:
댓글 쓰기
참고: 블로그의 회원만 댓글을 작성할 수 있습니다.