如果用户使用iPhone 5,我想增加自定义按钮的大小. 这就是我在.m文件中的内容 //.m Fileif(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){ CGSize result = [[UIScreen mainScreen] bounds].size; if(result.height
这就是我在.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的范围.
int varWidth;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
varWidth = 228;
}
if(result.height == 568)
{
varWidth = 272;
}
}
....
[newButton setFrame:CGRectMake(8.0, 40.0, varWidth, 80.0)];
