图片拉伸技巧
来源:互联网 发布:淘宝可以卖教程吗 编辑:程序博客网 时间:2024/05/29 09:18
图片拉伸技巧
*设置图标范围内的拉伸,保证自己想要的部分不变,有三种方法.
*方法一:
right = width - leftCapWidth - 1;bottom =height - topCapWidth - 1
[textBGstretchableImageWithLeftCapWidth:(NSInteger)
topCapHeight:(NSInteger)]
*方法二:
设置UIEdgeInsets属性.取要拉伸的部分.
[textBGresizableImageWithCapInsets:(UIEdgeInsets)]
*方法三:
设置UIEdgeInsets属性,和填充的样式UIImageResizingMode
[textBGresizableImageWithCapInsets:(UIEdgeInsets)
resizingMode:(UIImageResizingMode)];
举例子:
//自己发的是蓝色
UIImage *textBG = [UIImageimageNamed:@"chat_send_nor"];
CGFloat selectW =textBG.size.width*0.5;//取图横向中心位置
CGFloat selectH =textBG.size.height*0.5;//取图高中心位置
//取原图中,中心位置,来将扩大的部分填充.
UIImage *realTextBG = [textBGresizableImageWithCapInsets:UIEdgeInsetsMake(selectH,selectW,selectH,selectW)];
//将图添加上
[self.textViewsetBackgroundImage:realTextBG
forState:UIControlStateNormal];
文本计算尺寸
/**
*计算文字尺寸
* text 需要计算尺寸的文字
* font 文字的字体
* maxSize 文字的最大尺寸
*/
-(CGSize)sizeWithText:(NSString*)text font:(UIFont *)font maxSize:(CGSize)maxSize{
NSDictionary *attr =@{NSFontAttributeName:font}; //用字典接受
return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attr context:nil].size;
//计算出文本的大小}
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- IOS图片拉伸技巧
- iOS图片拉伸技巧
- IOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- iOS图片拉伸技巧
- 设计模型之二策略模式
- 类方法和对象方法的比较
- Excel和SQLserver数据互相存取
- 2015年8月25日工作日志----------------赵鑫
- 是什么冲击了原本的我,我变得如此脆弱
- 图片拉伸技巧
- iOS应用架构谈 view层的组织和调用方案
- python 问题
- Hazelcase 简介
- 如何更好地管理你的数据库——navicat(mysql)
- CS,七,软件工程
- Linux文件基本介绍
- 基本排序算法--快速排序
- 使用.NET中的XML注释(二) -- 创建帮助文档入门篇