5
是否可以在UINavigationBar的左側或右側邊緣上定位自定義圖像UIBarButton項?如果按鈕的邊緣觸及UINavigationBar的邊緣,我創建按鈕的方式看起來最好。在UINavigationBar的邊緣位置UIBarButtonItem
是否可以在UINavigationBar的左側或右側邊緣上定位自定義圖像UIBarButton項?如果按鈕的邊緣觸及UINavigationBar的邊緣,我創建按鈕的方式看起來最好。在UINavigationBar的邊緣位置UIBarButtonItem
這裏最好的選擇是繼承UINavigation欄和覆蓋佈局子視圖。
在我的例子我將我的按鈕,最左邊的邊緣,如果它有900
- (void) layoutSubviews {
[super layoutSubviews];
//override the navigation bar to move classes with 900 to the ledge
for (UIView *view in self.subviews) {
if ([view isKindOfClass:[UIButton class]]) {
if (view.tag == 900)
view.frame = CGRectMake(0,0, 88, 44);
}
}
}
標籤爲什麼不會是可能的嗎?你是用Interface Builder還是通過編程創建你的視圖? –
實際上使用情節提要。我寧願通過故事板創造一切。基本上,我只想輕鬆刪除右側UIBarButton右側的填充和左側UIBarButtonItem左側的填充。 – mhbdr