zoukankan      html  css  js  c++  java
  • iOS去除系统默认的图片和文字的渲染

    1.去除图片的系统默认渲染

      选中图片,设置属性Render As为Original Image

    代码控制:

    #import <UIKit/UIKit.h>

    @interface UIImage (HKExtension)

    @property(nonatomic,strong,readonly)UIImage * resizbleImage;

    @property(nonatomic,strong,readonly)UIImage * originarImage;

    +(UIImage *)hk_resizbleImage:(NSString *)name;

    +(UIImage *)imageWithOriginalNamed:(NSString *)name ;

    +(UIImage *)hk_imageWithOriginalNamed:(NSString *)name;

    @end

    #import "UIImage+HKExtension.h"

    @implementation UIImage (HKExtension)

    //不被渲染

    -(UIImage *)originarImage

    {

        return [self imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    }

    +(UIImage *)hk_imageWithOriginalNamed:(NSString *)name

    {

        UIImage * image = [UIImage imageNamed:name];

        return  [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    }

    //不被渲染

    +(UIImage *)imageWithOriginalNamed:(NSString *)name

    {

        UIImage * image = [UIImage imageNamed:name];

        return  [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    }

    //保护四周 拉伸中间一个像素点

    +(UIImage *)hk_resizbleImage:(NSString *)name

    {

        UIImage * image = [UIImage imageNamed:name];

        return [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];

    }

     @end

    2.去除文字渲染

     //设置应用程序中所有的UITabBarItem的属性

        UITabBarItem * item = [UITabBarItem appearance];//认为是一个皮肤

        //属性字典

        NSDictionary * dict = @{

                                NSFontAttributeName : [UIFont systemFontOfSize:12],

                                NSForegroundColorAttributeName : [UIColor grayColor]

                                };

        NSDictionary * dictSelect = @{ NSForegroundColorAttributeName : [UIColor darkGrayColor]};

        

        [item setTitleTextAttributes:dict forState:UIControlStateNormal];

        [item setTitleTextAttributes:dictSelect forState:UIControlStateSelected];

     注意:文字在选中状态下字体大小设置没有用,文字大小只能在normal状态下设置

  • 相关阅读:
    ZROI2018提高day9t1
    p2114 起床困难综合症
    EZOJ #78
    Linux JDK配置
    jps命令
    虚拟机 网卡模式配置
    redhat下yum命令安装(替换为centos yum命令)
    URL编码
    Query DSL(2)----Full text queries
    Query DSL(1)
  • 原文地址:https://www.cnblogs.com/PJXWang/p/5540244.html
Copyright © 2011-2022 走看看