[英]Ios :: toolbar alignment issue
我在xib文件中添加了工具栏。 但在ios6模拟器中无法正确显示。 它在ios4模拟器中显示完美。
以下是屏幕截图。
iPhone 6图片
Iphone4s图片
请向左滑动以删除图像中的工具栏,这在iPhone 4s中很好,但在iPhone 6模拟器中介于两者之间。
请帮助解决问题...
下面的代码修复了所有模拟器的问题。
//Caclulate the height of the toolbar
CGFloat toolbarHeight = [toolbar frame].size.height;
//Get the bounds of the parent view
CGRect rootViewBounds = [UIScreen mainScreen].bounds;
//Get the height of the parent view.
CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);
//Get the width of the parent view,
CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);
//Create a rectangle for the toolbar
CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight);
self.toolbar.frame = rectArea;
我把上面的代码放在viewWillAppear方法中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.