[英]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.