ios - 如何在 UIToolBar 框架和 UIToolBarItems 之间的行分隔符上添加平滑的低阴影

标签 ios swift uitoolbar uitoolbaritem

我正在尝试创建一个看起来像 image-1 的 UIToolBar,但是我的操作输出确实是 image-2。我如何在其 Items 之间添加 UIToolBar 的阴影层和分隔符?

我确实找到了这个关于分隔符的问题,但那里没有答案 -> Separator between toolbar items in UIToolbar

IMAGE-1

IMAGE-2

最佳答案

您可以查看此苹果文档:https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/UIKitUICatalog/UIToolbar.html#//apple_ref/doc/uid/TP40012857-UIToolbar

GitHub 上还有一个库选项: https://github.com/iosphere/ISHHoverBar

编辑:

这就是您使用库 (ViewDidLoad) 的方式

UIBarButtonItem *mapBarButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.mapView];
UIButton *infoButton = [UIButton      buttonWithType:UIButtonTypeInfoLight]; 
[infoButton addTarget:self action:@selector(toggleOrientation:) forControlEvents:UIControlEventTouchUpInside]; 
UIBarButtonItem *infoBarButton = [[UIBarButtonItem alloc] initWithCustomView:infoButton]; 
[self.hoverbar setItems:@[mapBarButton, infoBarButton]];

关于ios - 如何在 UIToolBar 框架和 UIToolBarItems 之间的行分隔符上添加平滑的低阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41501870/

相关文章:

swift - OS X 应用程序用逗号转换文本字段导致双值问题

ios - UITextField Swift 中 UIPicker 的 resignFirstResponder

ios - 从值是字典数组的字典中获取值

ios - 删除分组 UITableView 中各部分之间的垂直空间

ios - FirstViewController 在另一个 SecondViewController 之上,其中 SecondViewController 是可点击的

ios - 导航 Controller 定制不对应

iphone - iOS5.1设置UIToolbar背景图片

swift - 如何在 Swift 中对 UIBarButtonItem 应用垂直对齐

objective-c - 如何检查文件是否存在于特定的 URL?

ios - 如何在 UISlider 中显示 AVplayer 当前播放持续时间