学习是最好的投资!
Swift:
let leftBtn = UIButton(type: UIButtonType.Custom) leftBtn.frame = CGRectMake(0, 0, 65, 35) leftBtn.setImage(UIImage(named: "icon_xm_homepage_downArrow"), forState: UIControlState.Normal) leftBtn.adjustsImageWhenHighlighted = false
// leftBtn.setTitleColor(UIColor.brownColor(), forState: UIControlState.Normal) //Set button font color
leftBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center leftBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -50, 0, 0) leftBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 45, 0, 0) leftBtn.setTitle("天津", forState: UIControlState.Normal) leftBtn.addTarget(self, action: "showLeft", forControlEvents: UIControlEvents.TouchUpInside) self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: leftBtn)
Similar small icons generally have the following methods:
Use css sprites to set background-position to set this kind of small picture
Use an icon library, the more popular ones are Alibaba vector graphics library or bootstrap font icons
You can just write a caret-down class using css yourself
Meituan should use css sprites, which are relatively popular, have better compatibility and consume relatively less resources
It’s just a picture
http://s1.meituan.net/www/css/si/base.v21effb81.pngPictures, pick the one you like~
Try fontAwesome
Swift:
// leftBtn.setTitleColor(UIColor.brownColor(), forState: UIControlState.Normal) //Set button font color
Similar small icons generally have the following methods:
Use css sprites to set background-position to set this kind of small picture
Use an icon library, the more popular ones are Alibaba vector graphics library or bootstrap font icons
You can just write a caret-down class using css yourself
Meituan should use css sprites, which are relatively popular, have better compatibility and consume relatively less resources
It’s just a picture
http://s1.meituan.net/www/css/si/base.v21effb81.png
Pictures, pick the one you like~
Try fontAwesome