如果用户使用的是iPhone 5,我希望增加自定义按钮的大小。
这是我在.m文件中的代码:
//.m File
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
int varWidth = 228;
}
if(result.height == 568)
{
int varWidth = 272;
}
}
....
[newButton setFrame:CGRectMake(8.0, 40.0, 228, 80.0)];
但我想要像这样的东西:
[newButton setFrame:CGRectMake(8.0, 40.0, varWidth, 80.0)];
varWidth
定义为float
而不是integer
。 - Baby Groot