我正在开发我现有的应用程序以自定义屏幕以兼容 iPhone 5 屏幕。 但是,正如您在下图中看到的,我的 imageview 没有正确放置。我不知道我做错了什么。任何帮助表示赞赏! unlockView 代表箭头。 lockViewOutlet 图像代表箭头图像的外部。
- (void)viewDidLoad {
[super viewDidLoad];
float screenSizeHeight=[UIScreen mainScreen].bounds.size.height;
if(screenSizeHeight==568)
{
[lockViewOutlet setFrame:CGRectMake(0, 20, 320, 548)];
[unlockImageView setFrame:CGRectMake(24, 500, 68, 43)];
[unlockText setFrame:CGRectMake(105, 500, 182,43)];
}
if(screenSizeHeight==480)
{
[lockViewOutlet setFrame:CGRectMake(0, 20, 320, 460)];
[unlockImageView setFrame:CGRectMake(24, 411, 68, 43)];
[unlockText setFrame:CGRectMake(105, 411, 182,43)];
}
}
iPhone 5 截图 iphone 4 截图
最佳答案
好的,我明白了,
问题出在您的 ImageView lockViewOutlet 上。
在您的代码中:[lockViewOutlet setFrame:CGRectMake(0, 20, 320, 548)];
您尝试调整背景 imageView 的大小。 仅调整 imageView 的大小 并不能解决您的问题。真正的问题在于 lockViewOutlet.image 的大小。
最好的方法是设计一个大小为 320、568 的新图像。然后在调整 imageview 的大小后为 iphone 5 设置图像。
if(screenSizeHeight==568)
{
[lockViewOutlet setFrame:CGRectMake(0, 20, 320, 548)];
[lockViewOutlet setImage:[UIImage imageNamed:@"iPhone5LockNackground.png"]];
[unlockImageView setFrame:CGRectMake(24, 500, 68, 43)];
[unlockText setFrame:CGRectMake(105, 500, 182,43)];
}
关于ios - 从 iPhone 4 到 iPhone 5 - UIMageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16432238/