美文网首页
Storyboard--UITabBarController 使

Storyboard--UITabBarController 使

作者: 该名称已占用 | 来源:发表于2020-07-23 15:59 被阅读0次

利用storyboard新建UITabBarController时,在设置好ImageSelected Image之后,图片不能正常显示,选中时为蓝色,未选中时为灰色,没有正确显示图片样式。
Storyboard设置:

截屏2020-07-23 下午4.07.32.png

显示效果:

Jul-23-2020 16-06-02.gif
可以发现,图片的边框是加载出来了,不过没有正常渲染

主要是因为storyboard默认渲染了设置的图片,在设置普通的Image时候不会出现问题,不过在Tab bar Item的时候需要更改一下UIImagewithRenderingMode属性,通过查阅API文档,可以看到有以下几种设置方式

/* Images are created with UIImageRenderingModeAutomatic by default.
 An image with this mode is interpreted as a template image or an original image based on the context in which it is rendered. 
For example, navigation bars, tab bars, toolbars, and segmented controls automatically treat their foreground images as templates, while image views and web views treat their images as originals. 
You can use UIImageRenderingModeAlwaysTemplate to force your image to always be rendered as a template or UIImageRenderingModeAlwaysOriginal to force your image to always be rendered as an original.
     */
 @available(iOS 7.0, *)
    public enum RenderingMode : Int {

        
        case automatic = 0 // Use the default rendering mode for the context where the image is used

        
        case alwaysOriginal = 1 // Always draw the original image, without treating it as a template

        case alwaysTemplate = 2 // Always draw the image as a template image, ignoring its color information
    }

我们需要把设置modeUIImageRenderingModeAlwaysOriginal
新建一个类,继承 UITabBarController,更改StoryboardSceneclass即可

截屏2020-07-23 下午4.23.59.png

效果图:


Jul-23-2020 16-30-06.gif

相关文章

  • Storyboard--UITabBarController 使

    利用storyboard新建UITabBarController时,在设置好Image和Selected Imag...

  • 借你耳朵使使

    最近,偶然发现有音频类的APP很火,便也下载了一个。这个还真不错:小说、相声、童话故事、古诗词解读……几乎囊括了所...

  • 君子使物,不为物使

    “君子使物,不为物使”是我曾读《菜根谭》中所看到的一句话,当时这句话引起了我的主意,我想起曾经自己深受手机的控制而...

  • 谁借我点脑子使使

    一直以来,我都坚信自己的脑容量太小,脑子从来没够用过,正如天气预报从来没准过一样。 有热心的不服气的网友(俗称轴脾...

  • 君子使物,不为物使

    我愿意深深地扎入生活,吮尽生活的骨髓,过得扎实,简单,把一切不属于生活的内容剔除得干净利落,把生活逼到绝处,用最基...

  • 君子使物,不为物使

    《世说新语》中记载了两则发人深省的小故事: 一则是“阮裕焚车”的故事——阮裕曾有一辆非常好的车子,无论谁来借,他都...

  • 使人快乐使己快乐

    “哎,你发现没有,给别人带来快乐的同时,自己也会获得同样的快乐,甚至是加倍的快乐。” “是吗?” “这还用怀疑吗?...

  • 勾魂使

    我自幽冥深处走过 勾引着世间万物的魂魄 有人享受着人间极乐 有人饱受着艰难困惑 不管如何 我都冷眼旁观 紧盯着灵魂...

  • 阴阳使

    (一)死人 夜幕降临,刚刚栖在树上的乌鸦被一声惊叫惊得飞上天空,几根黑羽轻飘飘掉落在树林下。 天空中,一轮明月冷眼...

  • 冬使

    冥冥落梦三秋去, 冰潭镜影大鹰飞。 往往旋花千里漠, 拂氅开雪送春归。 20161219

网友评论

      本文标题:Storyboard--UITabBarController 使

      本文链接:https://www.haomeiwen.com/subject/yeshlktx.html