1
我想打一個按鈕在我的應用程序旋轉,和我有下面這段代碼:如何避免使用CGAffineTransform時文字消失?
- (void)setFrameForButton:(UIButton *)ok {
if ([[UIDevice currentDevice] isWildcat]) {
if([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
ok.frame = CGRectMake(244, 840, 280, 20);
if (wasChanging) ok.transform = CGAffineTransformMakeRotation(M_PI * -0.50);
}
else {
ok.frame = CGRectMake(372, 584, 280, 20);
if (wasChanging) ok.transform = CGAffineTransformMakeRotation(M_PI * -0.50);
}
}
else {
ok.frame = CGRectMake(15.0, 375.0 ,280.0, 20.0);
}
if (wasChanging) wasChanging = NO;
}
- (void)window:(id)window willRotateToInterfaceOrientation:(int)orientation duration:(double)duration {
wasChanging = YES;
[self setFrameForButton:btn];
}
雖然當我旋轉的位置應該被改變,以下一些輪換後,在我的按鈕上的文本消失。該怎麼辦?