0
很遺憾UIToolbar
不支持UIBarbuttonItem
元素的大小分類。如何在UIToolbar
上隱藏UIBarbuttonItem
的小尺寸課程?如何在UIToolbar上爲小尺寸類隱藏UIBarbuttonItem?
很遺憾UIToolbar
不支持UIBarbuttonItem
元素的大小分類。如何在UIToolbar
上隱藏UIBarbuttonItem
的小尺寸課程?如何在UIToolbar上爲小尺寸類隱藏UIBarbuttonItem?
首先,補充一點:
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
if ((self.traitCollection.verticalSizeClass != previousTraitCollection.verticalSizeClass)
|| (self.traitCollection.horizontalSizeClass != previousTraitCollection.horizontalSizeClass)) {
[self setupToolbar:self.traitCollection.horizontalSizeClass];
}
}
,然後重新創建工具欄項目:
if (horizontalSizeClass == UIUserInterfaceSizeClassCompact) {
mainItems = [NSArray arrayWithObjects:..., nil];
} else {
mainItems = [NSArray arrayWithObjects:..., nil];
}
[mainToolbar setItems:mainItems animated:NO];