view旋轉(zhuǎn)中心不變 和強(qiáng)制橫屏

view旋轉(zhuǎn)保證中心不變

view的動(dòng)畫效果

- (void)isShowLoadingInView:(UIView *)view meet:(NSString *)meet {

? ? if (!view) {

? ? ? ? return;

? ? }

? ? self.meetName.text = meet;

? ? [view addSubview:self];

? ? [UIView animateWithDuration:0.3 animations:^{

? ? ? ? self.alpha = 1;

? ? ? ? float centerX = view.bounds.size.width/2;

? ? ? ? float centerY = view.bounds.size.height/2;

? ? ? ? float x = view.bounds.size.width/2;

? ? ? ? float y = view.bounds.size.height;


? ? ? ? CGAffineTransform trans = GetCGAffineTransformRotateAroundPoint(centerX,centerY ,x ,y ,-90.0/180.0*M_PI);

? ? ? ? view.transform = CGAffineTransformIdentity;

? ? ? ? view.transform = trans;

? ? } completion:nil];

}

CGAffineTransform GetCGAffineTransformRotateAroundPoint(float centerX, float centerY ,float x ,float y ,float angle)

{

? ? x = x - centerX; //計(jì)算(x,y)從(0,0)為原點(diǎn)的坐標(biāo)系變換到(CenterX ,CenterY)為原點(diǎn)的坐標(biāo)系下的坐標(biāo)

? ? y = y - centerY; //(0,0)坐標(biāo)系的右橫軸、下豎軸是正軸,(CenterX,CenterY)坐標(biāo)系的正軸也一樣


? ? CGAffineTransform? trans = CGAffineTransformMakeTranslation(x, y);

? ? trans = CGAffineTransformRotate(trans,angle);

? ? trans = CGAffineTransformTranslate(trans,-x, -y);

? ? return trans;



強(qiáng)制橫屏,其他頁(yè)面都是豎屏,需要橫屏的頁(yè)面添加方法

- (BOOL)shouldAutorotate {

? ? return NO;

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {

? ? return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

? ? return UIInterfaceOrientationLandscapeRight;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容