样式 | 图片 |
UIBarButtonSystemItemDone | |
UIBarButtonSystemItemCancel | |
UIBarButtonSystemItemEdit | |
UIBarButtonSystemItemSave | |
UIBarButtonSystemItemAdd | |
UIBarButtonSystemItemFlexibleSpace | 无样式 |
UIBarButtonSystemItemFixedSpace | 无样式 |
UIBarButtonSystemItemCompose | |
UIBarButtonSystemItemReply | |
UIBarButtonSystemItemAction | |
UIBarButtonSystemItemOrganize | |
UIBarButtonSystemItemBookmarks | |
UIBarButtonSystemItemSearch | |
UIBarButtonSystemItemRefresh | |
UIBarButtonSystemItemStop | |
UIBarButtonSystemItemCamera | |
UIBarButtonSystemItemTrash | |
UIBarButtonSystemItemPlay | |
UIBarButtonSystemItemPause | |
UIBarButtonSystemItemRewind | |
UIBarButtonSystemItemFastForward | |
UIBarButtonSystemItemUndo | |
UIBarButtonSystemItemRedo | |
UIBarButtonSystemItemPageCurl |
可能有同学注意到 UIBarButtonSystemItemFlexibleSpace 和 UIBarButtonSystemItemFixedSpace 两个是无样式的.
那他们是做什么用的呢?
他们不是按钮,而是调整按钮间距用的对象.
让4个按钮等间距地分布在工具条中,在使用UIViewController的setToolbarItems:方法 追加按钮时,如下述代码一样在4个按钮之间追加IBarButtonSys
temItemFlexibleSpace对象即可。
例如下图:
首先创建方法
- (UIBarButtonItem*)barButtonSystemItem :(UIBarButtonSystemItem) systemItem {
UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:systemItem target:nil action:nil];
return button;
}
调用
[self setToolbarItems:[NSArray arrayWithObjects:[self barButtonSystemItem:UIBarButtonSystemItemAction],
[self barButtonSystemItem:UIBarButtonSystemItemFlexibleSpace],
[self barButtonSystemItem:UIBarButtonSystemItemBookmarks],
[self barButtonSystemItem:UIBarButtonSystemItemFlexibleSpace],
[self barButtonSystemItem:UIBarButtonSystemItemCancel],
[self barButtonSystemItem:UIBarButtonSystemItemFlexibleSpace],
[self barButtonSystemItem:UIBarButtonSystemItemEdit],nil]];
在调用的过程中,使用 UIBarButtonSystemItemFlexibleSpace去占位,达到实现规范化的目的
实现效果:
相应的 UIBarButtonSystemItemFixedSpace则是使特定位置控件替代.
更多精彩文章,尽在我的公众号.