[英]iphone background images when changing device rotation
我的控件后面有一个UIImageView
作为背景,旋转设备时出现问题。 我想根据orientation
使用不同的image
。
那么处理这个问题的最佳方法是什么? 为横向和纵向添加和删除每个UIImageView
? 既有视图又有隐藏/显示合适的视图? 或者也许有一些 class 或UIObject
来处理?
TIA
现在,您实际上可以为此目的使用尺寸等级。 您需要做的就是为 Any width compact height 设置图像并执行本文中给出的提示: http://pinkstone.co.uk/how-to-handle-device-rotation-since-ios-8/那就是旋转时更改背景图像所需的一切。
您可以将其图像属性设置为不同的图像。
someUIImageView.image = [UIImage imageNamed:@"foo.png"];
您可以使用它变得时髦,并叠加两个背景图像,一个具有 alpha = 1.0,另一个具有 alpha = 0.0。 然后,当您旋转时,使用 animation 将 alpha 分别转换为 0.0 和 1.0,以获得淡入淡出效果。 如果选择这种方式,我建议将 animation 代码放在-viewWillAppear:
例如,像这样:
[UIView beginAnimations:nil context:NULL]; {
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
if (toOrientation == UIInterfaceOrientationLandscape) {
landscapeView.alpha = 1.0;
portraitView.alpha = 0.0;
}
else {
landscapeView.alpha = 0.0;
portraitView.alpha = 1.0;
}
} [UIView commitAnimations];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.