概述 //设置tool private func prepareToolBar(){ let toolBar = UIToolbar() view.addSubview(toolBar) let w = UIScreen.mainScreen().bounds.size.width toolBar.ff_A //设置tool private func preparetoolbar(){ let toolbar = UIToolbar() vIEw.addSubvIEw(toolbar) let w = UIScreen.mainScreen().bounds.size.wIDth toolbar.ff_AlignInner(type: ff_AlignType.Bottomleft,referVIEw: vIEw,size: CGSize(wIDth: w,height: 44)) let items = [["imagename": "compose_toolbar_picture"],["imagename": "compose_mentionbutton_background"],["imagename": "compose_trendbutton_background"],["imagename": "compose_emoticonbutton_background"],["imagename": "compose_addbutton_background"]] //初始化一个按钮的数组 var btnItems = [UIbarbuttonItem]() for dict in items{ btnItems.append(UIbarbuttonItem(customVIEw: UIbutton(imagename: dict["imagename"]!))) btnItems.append(UIbarbuttonItem(barbuttonSystemItem: UIbarbuttonSystemItem.FlexibleSpace,target: nil,action: nil)) } //移除最后一个拉伸d簧 btnItems.removeLast() toolbar.items = btnItems } //配合分类 extension UIbutton{ /// 便利构造函数 /// /// - parameter imagename: 图像名称 /// /// - returns: UIbutton convenIEnce init(imagename: String){ self.init() setimage(UIImage(named: imagename),forState: UIControlState.normal) setimage(UIImage(named: imagename + "_highlighted"),forState: UIControlState.Highlighted) sizetoFit() } } 总结
以上是内存溢出为你收集整理的Swift自定义Tool全部内容,希望文章能够帮你解决Swift自定义Tool所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
评论列表(0条)