【发布时间】:2015-04-30 19:25:06
【问题描述】:
我有一个应用程序,我希望在点击另一个按钮时在不同设备上更改按钮的框架大小。当我点击 iPad 上的按钮时,另一个按钮的框架大小会改变,并在点击另一个按钮时变回。但是,在 iPhone 上不会发生这种情况。
这是 iphone 上的原始尺寸 (568高度) button.frame = CGRectMake(18,456,126,13);
其他高度 button.frame = CGRectMake(18,370,126,13);
这是 iPad 上的尺寸
button.frame = CGRectMake(47,577,251,26);
这是在点击另一个按钮时更改按钮大小的代码
-(IBAction)changeSize:(id)sender{
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
int height = [UIScreen mainScreen].bounds.size.height;
if (height == 568) {
self.button.frame = CGRectMake(18,339,100,13);
}
else {
self.button.frame = CGRectMake(18,279,100,13);
}
}
else if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
self.button.frame = CGRectMake(47,603,200,26);
}
就像我说的那样,在 iPad 上更改按钮大小效果很好,但在 iPhone 上却不行。 有什么建议吗?
谢谢
【问题讨论】:
标签: uibutton xcode6 cgrectmake