Some points of note for Swift-tabbar picture settings

Source: Internet
Author: User

Picture size size
刚刚开始接触的话,从美工那边拿来的图标大小一般都是偏大的,就像这样:

在此建议,tabBar的图标大小可以是32*32,个人感觉效果不错
Color problems with pictures
如所示,该图标的期望颜色(也就是美工给的原图)如所示:

那么问题来了,为什么会变成灰色的呢?经查阅后得知。这是因为在默认情况下,未选中状态图片和字体颜色为灰色,选中状态片和字体颜色为蓝色。

</*************************************** Solutions *************************************************/>

法1:通过xib面板设置 —— 点击Assets.xcassets找到相应的图片

将此处的Render As:Default 改为 Original Image

法2:用代码方式实现 —— 将对应的UITabBarItem连线到FirstViewController,然后按照如下实现:

import UIKit
class FirstViewController: UIViewController {
@IBOutlet weak var tab1: UITabBarItem!
override func viewDidLoad() {
super.viewDidLoad()
tab1.image = UIImage(named: "tab1")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
tab1.selectedImage = UIImage(named:"tab1")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
// Do any additional setup after loading the view.
}
}

Some points of note for Swift-tabbar picture settings

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.