1
我創建了一個UIToolBar以編程方式,它工作正常,除了iPhone X,我希望工具欄根據手機的方向展開。如果工具欄是使用界面構建器創建的,則擴展工作。iOS 11 UIToolBar自動擴展
我沒有設置任何高度限制,甚至隱式地通過自動佈局遮罩。
代碼:
UIToolbar* toolbar = [[UIToolbar alloc] init];
toolbar.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:toolbar];
[self.view addConstraints:@[
[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:toolbar attribute:NSLayoutAttributeLeft multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:toolbar attribute:NSLayoutAttributeBottom multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:toolbar attribute:NSLayoutAttributeRight multiplier:1 constant:0]]];
所以,我應該怎麼辦要使工具欄的行爲是否正確?
我相信底部工具欄中的新高度差異是爲了解釋屏幕底部的「抓取條」,以指導用戶「輕掃回家」的姿勢。 –
@BenKreeger是的,這是由我寫的。我不知道的是如何處理這個事實,即使固有尺寸是49,但約束條件有時仍然保持在44.並且對於XIB似乎不會發生。 – Rychu