可以將UIView對象的位置及尺寸變化處理成動畫效果

基本的動畫處理方式
//標識動畫的開始位置 + (void)beginAnimations:(NSString *)animationID context:(void *)context //標識動畫的結束位置,并開始動畫 + (void)commitAnimations //設置動畫執行時間,單位為秒 + (void)setAnimationDuration:(NSTimeInterval)duration //動畫重復次數,默認為1 + (void)setAnimationRepeatCount:(float)repeatCount
如:通過改變btn的大小使用動畫處理
CGRect frame = self.btn.frame; frame.size.width *= 1.2; frame.size.height *= 1.2; [UIView beginAnimations:@"btn" context:nil]; [UIView setAnimationDuration:0.5]; self.btn.frame = frame; [UIView commitAnimations];
block方式的動畫處理
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delayoptions:(UIViewAnimationOptions)options animations:(void (^)(void))animationscompletion:(void (^)(BOOL finished))completion
如:
CGRect frame = self.btn.frame;
frame.size.width *= 1.2;
frame.size.height *= 1.2;
[UIView animateWithDuration:0.5 animations:^{
self.btn.frame = frame;
}];動畫處理中使用形變屬性
動畫處理中使用形變屬性是一個非常好的做法
基于自身初始形變值進行形變:
//位置形變 CGAffineTransform CGAffineTransformMakeTranslation ( CGFloat tx, CGFloat ty ); //尺寸形變 CGAffineTransform CGAffineTransformMakeScale ( CGFloat sx, CGFloat sy ); //旋轉形變 CGAffineTransform CGAffineTransformMakeRotation ( CGFloat angle );
基于指定形變值進行形變:
//位置形變 CGAffineTransform CGAffineTransformTranslate ( CGAffineTransform t, CGFloat tx,CGFloat ty ); //尺寸形變 CGAffineTransform CGAffineTransformScale ( CGAffineTransform t, CGFloat sx,CGFloat sy ); //旋轉形變 CGAffineTransform CGAffineTransformRotate ( CGAffineTransform t, CGFloat angle );
如:
CGAffineTransform transform = CGAffineTransformScale(self.btn.transform, 1.2, 1.2); [UIView beginAnimations:@"btn" context:nil]; [UIView setAnimationDuration:0.5]; self.btn.transform = transform; [UIView commitAnimations];
形變原始值常量:
const CGAffineTransform CGAffineTransformIdentity;
另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
網站題目:UIKit框架(3)UIView的動畫處理方式-創新互聯
轉載來源:http://www.yijiale78.com/article8/hhoop.html
成都網站建設公司_創新互聯,為您提供標簽優化、關鍵詞優化、靜態網站、網站排名、App設計、營銷型網站建設
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯