@property (nonatomic,strong) UIView *maskLayer;//遮罩層
@property (nonatomic,strong) UIView *popView;//底部pop的view
//第一次轉(zhuǎn)換
- (CATransform3D)getFirstTransform{
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -900.0;
transform = CATransform3DScale(transform, 0.95, 0.95, 1.0);
transform = CATransform3DRotate(transform, (CGFloat)(15.0*M_PI/180.0), 1, 0, 0);
transform = CATransform3DTranslate(transform, 0, 0, -55.0);
return transform;
}
//第二次轉(zhuǎn)換
- (CATransform3D)getSecondTransform{
CATransform3D transform = CATransform3DIdentity;
transform.m34 = [self getFirstTransform].m34;
transform = CATransform3DTranslate(transform, 0, self.view.frame.size.height * -0.08,0);
transform = CATransform3DScale(transform, 0.8, 0.8, 1.0);
return transform;
}
//開始動畫
- (void)openAnimation{
[self.view addSubview:self.maskLayer];
[[UIApplication sharedApplication].keyWindow addSubview:self.popView];
[UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor blackColor];
CGRect rect = self.popView.frame;
rect.origin.y = kScreenHeight / 3 * 2;
[UIView animateWithDuration:0.2 animations:^{
self.view.layer.transform = [self getFirstTransform];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.15 animations:^{
self.view.layer.transform = [self getSecondTransform];
self.maskLayer.alpha = 0.5;
self.popView.frame = rect;
}];
}];
}
//關(guān)閉動畫
- (void)closeAnimation{
CGRect rect = self.popView.frame;
rect.origin.y = kScreenHeight / 2 + rect.size.height + 49;
[UIView animateWithDuration:0.25 animations:^{
self.view.layer.transform = [self getFirstTransform];
self.popView.frame = rect;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.2 animations:^{
self.view.layer.transform = CATransform3DIdentity;
self.maskLayer.alpha = 0;
} completion:^(BOOL finished) {
[self.maskLayer removeFromSuperview];
[self.popView removeFromSuperview];
[UIApplication sharedApplication].keyWindow.backgroundColor = [UIColor whiteColor];
}];
}];
}
- (void)close{
[self closeAnimation];
self.navigationController.navigationBar.hidden = NO;
self.tabBarController.tabBar.hidden = NO;
}
//遮罩層
- (UIView *)maskLayer{
if (!_maskLayer) {
_maskLayer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 44)];
_maskLayer.backgroundColor = [UIColor blackColor];
_maskLayer.alpha = 0.7;
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
effectview.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
[_maskLayer addSubview:effectview];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = _maskLayer.bounds;
[button addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
[_maskLayer addSubview:button];
}
return _maskLayer;
}
- (UIView *)popView{
if (!_popView) {
_popView = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight, kScreenWidth, kScreenHeight / 3)];
_popView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
}
return _popView;
}
iOS-CATransform3D的轉(zhuǎn)場動畫
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來九默,“玉大人震放,你說我怎么就攤上這事⊥招蓿” “怎么了殿遂?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長乙各。 經(jīng)常有香客問我墨礁,道長,這世上最難降的妖魔是什么耳峦? 我笑而不...
- 正文 為了忘掉前任恩静,我火速辦了婚禮,結(jié)果婚禮上蹲坷,老公的妹妹穿的比我還像新娘蜕企。我一直安慰自己,他們只是感情好冠句,可當(dāng)我...
- 文/花漫 我一把揭開白布轻掩。 她就那樣靜靜地躺著,像睡著了一般懦底。 火紅的嫁衣襯著肌膚如雪唇牧。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼崖蜜,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了客峭?” 一聲冷哼從身側(cè)響起豫领,我...
- 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎舔琅,沒想到半個月后等恐,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年课蔬,在試婚紗的時候發(fā)現(xiàn)自己被綠了囱稽。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布横缔,位于F島的核電站铺遂,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏茎刚。R本人自食惡果不足惜襟锐,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望膛锭。 院中可真熱鬧粮坞,春花似錦、人聲如沸初狰。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽奢入。三九已至筝闹,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間腥光,已是汗流浹背关顷。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長得像捉片,于是被迫代替她去往敵國和親平痰。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 在第10章“緩沖”中伍纫,我們研究了 CAMediaTimingFunction 觉增,它是一個通過控制 動畫緩沖來模擬物...
- 一言不合先上效果圖 實(shí)現(xiàn)思路分析 在微博逾礁、簡書、百思這些app中的底部tabbar的中間會有一個提供給用戶的發(fā)布按...
- 文|張看 1、一個和尚配并,一個頭陀括荡,兩個人赤身裸體死在一塊,這在薊州是個大新聞溉旋,全城開啟八卦模式畸冲。沒文采的小混混,那...