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;
}