新建乙個view-based模板工程,在viewcontroller檔案中新增下面的**,即可實現翻轉效果;
- (void)viewdidload {
[super viewdidload];
//需要翻轉的檢視
uiview *parentview = [[uiview alloc] initwithframe:cgrectmake(0, 150, 320, 200)];
parentview.backgroundcolor = [uicolor yellowcolor];
parentview.tag = 1000;
[self.view addsubview:parentview];
//需要在h標頭檔案宣告下面的動作響應函式
//在xib檔案中新增乙個button,其響應函式為下面的函式
//執行程式後,點選button就看到翻轉效果
-(ibaction)actionfanzhuan{
//獲取當前畫圖的裝置上下文
cgcontextref context = uigraphicsgetcurrentcontext();
//開始準備動畫
[uiview beginanimations:nil context:context];
//設定動畫曲線,翻譯不准,見蘋果官方文件
[uiview setanimationcurve:uiviewanimationcurveeaseinout];
//設定動畫持續時間
[uiview setanimationduration:1.0];
//因為沒給viewcontroller類新增成員變數,所以用下面方法得到viewdidload新增的子檢視
uiview *parentview = [self.view viewwithtag:1000];
//設定動畫效果
[uiview setanimationtransition: uiviewanimationtransitioncurldown forview:parentview cache:yes]; //從上向下
// [uiview setanimationtransition: uiviewanimationtransitioncurlup forview:parentview cache:yes]; //從下向上
// [uiview setanimationtransition: uiviewanimationtransitionflipfromleft forview:parentview cache:yes]; //從左向右
// [uiview setanimationtransition: uiviewanimationtransitionflipfromright forview:parentview cache:yes];//從右向左
//設定動畫委託
[uiview setanimationdelegate:self];
//當動畫執行結束,執行animationfinished方法
[uiview setanimationdidstopselector:@selector(animationfinished:)];
//提交動畫
[uiview commitanimations];
//動畫效果執行完畢
- (void) animationfinished: (id) sender{
nslog(@"animationfinished !");
iOS 雷達掃瞄效果 實現
1 rotationanimation.removedoncompletion no 23 rotationanimation.fillmode kcafillmodeforwards fillmode的作用就是決定當前物件過了非active時間段的行為.比如動畫開始之前,動畫結束之後。如果是乙個動...
iOS下拉列表效果實現
控制項的屬性以及介面 主按鈕 可以自定義樣式 可在.m檔案中修改預設的一些屬性 property nonatomic,strong uibutton mainbtn property nonatomic,assign id delegate 下拉列表中的選項標題以及選項高度的設定 一些其他具體樣式的...
iOS為UIView設定陰影效果
uiview的陰影設定主要通過uiview的layer的相關屬性來設定 陰影的顏色 im iew.layer.shadowcolor uicolor bhxyhlxtbarlackcolor cgcolor 陰影的透明度 im iew.layer.shadowopacity 0.8f 陰影的圓角 i...