//------------------------------------------------------------------------------
// 2D 변환
// CGAffineTransform 을 사용하면 된다.
// 대상뷰의 transform 에 적용시킨다.
//------------------------------------------------------------------------------
* CGAffineTransformMakeScale(CGFloat sx, CGFloat sy)
x축 y축으로 확대/축소
* CGAffineTransformMakeRotation(CGFloat angle)
z축으로 회전
* CGAffineTransformMakeTranslation(CGFloat tx, CGFloat ty)
x축 y축으로 이동
* CGAffineTransformScale(CGAffineTransform t, CGFloat sx, CGFloat sy)
기존의 변환에 확대/축소 를 더한다.
* CGAffineTransformRotate(CGAffineTransform t, CGFloat angle)
기존의 변환에 회전을 더한다
* CGAffineTransformTranslate(CGAffineTransform t, CGFloat tx, CGFloat ty)
기존의 변환에 이동을 더한다
* 2D변환 애니메이션 사용 예제
void (^blockAnimation) (void);
void (^blockAnimationCompletion) (BOOL finished);
blockAnimation = ^(void)
{
대상뷰.transform = CGAffineTransformMakeRotation(-1.0);
};
blockAnimationCompletion = ^(BOOL finished)
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
대상뷰.transform = CGAffineTransformMakeRotation(1.0);
[UIView commitAnimations];
};
[UIView animateWithDuration:0.3 animations:blockAnimation completion:blockAnimationCompletion];
//------------------------------------------------------------------------------
// 3D 변환
// CATransform3D 를 사용하면 된다.
// 대상뷰의 layer.transform 에 적용시킨다.
//------------------------------------------------------------------------------
* CATransform3DMakeScale(CGFloat sx, CGFloat sy, CGFloat sz)
x축 y축 z축으로 확대/축소
* CATransform3DMakeRotation(CGFloat angle, CGFloat x, CGFloat y, CGFloat z)
x축 y축 z축으로 회전
* CATransform3DMakeTranslation(CGFloat tx, CGFloat ty, CGFloat tz)
* 3D변환 애니메이션 사용 예제
CATransform3D transform3D;
transform3D = CATransform3DIdentity;
void (^blockAnimation) (void);
void (^blockAnimationCompletion) (BOOL finished);
blockAnimation = ^(void)
{
대상뷰.layer.transform = CATransform3DScale(transform3D, 0.9, 0.9, 1.0);
};
blockAnimationCompletion = ^(BOOL finished)
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
대상뷰.layer.transform = CATransform3DScale(transform3D, 1.0, 1.0, 1.0);
[UIView commitAnimations];
};
[UIView animateWithDuration:0.3 animations:blockAnimation completion:blockAnimationCompletion];
'iOS 초보' 카테고리의 다른 글
GPUImage 사용 (0) | 2016.09.21 |
---|---|
Barcode 이미지 생성하기 (0) | 2016.08.26 |
facebook sdk, FBSDKLoginManager, 로그인 연동 (0) | 2016.04.08 |
UITextField. Placeholder. 색 변경 (0) | 2016.04.07 |
cocoapods 설치. 사용법 (0) | 2015.11.05 |