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

时间: 2024-08-02 02:49:50

iOS去除系统默认的图片和文字的渲染的相关文章

iOS TabbarController 设置底部Toolbar图片和文字颜色选中样式

提取公共方法: -(void)createChildVcWithVc:(UIViewController *)vc Title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage { //图片渲染 vc.tabBarItem.title=title; vc.navigationItem.title=title; vc.tabBarItem.image=[UIImage imageNam

Android去除系统默认的标题栏和全屏的三种方法

在做应用的时候,很多时候是不需要系统自带的标题栏的,而是自己去实现标题栏,这就要去掉系统的标题栏,下面总结了三种方法.全屏也是一样的道理,也总结了实现的三种方法. (一)去除标题栏 1.方法1 在Activity的onCreate方法中: 1 requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 2 //注意这句一定要写在setContentView()方法的前面,不然会报错的 但是这种方法的缺陷是,因为在onCreate方法中才去掉标题栏,

c# 调用系统默认图片浏览器打开图片

private void OpenImage(string fileName) { try { Process.Start(fileName); } catch (Exception ex) { // LogHelper.WriteLog("调用默认看图软件打开失败", ex); try { string arg = string.Format( "\"{0}\\Windows Photo Viewer\\PhotoViewer.dll\", ImageV

仿新浪微博IOS客户端(v5.2.8)——自定义UITabBar替换系统默认的(添加“+”号按钮)

转载请标明出处:http://blog.csdn.net/android_ls/article/details/45896395 声明:仿新浪微博项目,所用所有图片资源都来源于官方新浪微博IOS客户端,编写本应用的目的在于学习交流,如涉及侵权请告知,我会及时换掉用到的相关图片. 自定义UITabBar替换系统默认的,目的是为了在UITabBar中间位置添加一个"+号按钮",下面我们来聊聊具体的实现. 1.自定义WBTabBar,让其继承自UITabBar,代码如下: // // WBT

IOS 给图片添加水印(文字)

有时候上传图片要加唯一标识,简单的就是添加一个水印.这里水印我们讲文字,可以是当前系统时间.坐标.地理位置等 原理就是把一个字符串写到图片上,并且字(font)的大小由图片大小控制. 以下是封装好的一个类方法: //NavView.m + (UIImage *) addText:(UIImage *)img text:(NSString *)mark { int w = img.size.width; int h = img.size.height; UIGraphicsBeginImageCo

iOS设置导航与其标题的颜色及字体大小和系统默认TabBar的相关设置与使用方法

第一步: //在info.plist中添加一个字段:view controller -base status bar 设置为NO://导航颜色[[UINavigationBar appearance] setBarTintColor:[UIColor XXXX]];[[UITableViewCell appearance] setBackgroundColor:[UIColor XXXX]]; //设置状态栏(信号区)白色[[UIApplication sharedApplication] se

Android 调用系统的分享[完美实现同时分享图片和文字]

android 系统的分享功能 private void share(String content, Uri uri){ Intent shareIntent = new Intent(Intent.ACTION_SEND); if(uri!=null){ //uri 是图片的地址 shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/*"); //当用户选择短信时使用sms_body取得文

iOS开发——UI高级OC篇&amp;自定义控件之调整按钮中子控件(图片和文字)的位置

自定义控件之调整按钮中子控件(图片和文字)的位置 其实还有一种是在storyBoard中实现的,只需要设置对应空间的左右间距: 这里实现前面两种自定义的方式 一:imageRectForContentRect/titleRectForContentRect 自定义一个按钮控件在系统自带的位置设置方法中实现对应子控件位置调整 1 /** 2 3 * 设置内部图标的frame 4 5 */ 6 7 - (CGRect)imageRectForContentRect:(CGRect)contentRe

ios代码调整button图片image文字title位置

自定义一个button,要调整 button中的image(注意,不是backgroundImage) 和  title 文字的位置,只需要重写  Button类独对应的两个方法即可: 首先,我们来创建一个 SuperButton继承自 UIButton // // SuperButton.h // SuperButton // // Created by 杨斌 on 14/12/25. // Copyright (c) 2014年 杨斌. All rights reserved. // #im