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状态下设置

  • 相关阅读:
    MySQL 存储过程和函数02
    MySQL 视图 存储过程(未完)
    MySQL 简单索引
    Nginx 设置前后端跨域
    Pipeline流水线 自动脚本
    luogu 2024 食物链
    spoj Corporative Network
    luogu2787 语文1(chin1)- 理理思维
    HDU6579 Operation
    luogu3857 彩灯
  • 原文地址:https://www.cnblogs.com/PJXWang/p/5540244.html
Copyright © 2011-2022 走看看