iOS小技巧2
这段代码是实现了类似QQ空间"我的空间"里面的圆形头像
//圆形的头像
UIImageView * headImage = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
headImage.backgroundColor = [UIColor grayColor];
headImage.image = [UIImage imageNamed:@"headimage.jpg"];
headImage.clipsToBounds = YES;
headImage.layer.cornerRadius = headImage.bounds.size.width/;
headImage.layer.borderWidth = ;
headImage.layer.borderColor = [UIColor yellowColor].CGColor;
[self.view addSubview:headImage];
创建具有中划线的文字 NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]}; NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:@"价格:40" attributes:attribtDic];
label.attributedText = attribtStr
在使用target-action模式的时候, 在ARC模式下会有内存提示. 用这几句代码可以消除提示. (强迫症福音)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[_target performSelector:_action withObject:self];
# pragma clang diagnostic pop
设置UISearchBar的背景颜色 今天用到UISearchBar,之前网上提供的方法已经不能有效的去除掉它的背景色了,修改背景色方法如下:
mySearchBar.backgroundColor = RGBACOLOR(,,,);
mySearchBar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:mySearchBar.bounds.size]; //取消searchbar背景色
- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
CGRect rect = CGRectMake(, , size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect); UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); return image;
}
ios tableView上面空出20个像素的解决办法 tableView上面多出来20个像素,是因为自动布局的缘故,设置一下属性就可以解决问题
self.edgesForExtendedLayout = UIRectEdgeNone;
下面代码解决cell重用,贴出来方便下次使用
//解决cell重用
while ([cell.contentView.subviews lastObject] != nil) {
[(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
}
iOS小技巧2的更多相关文章
- iOS小技巧总结,绝对有你想要的
原文链接 在这里总结一些iOS开发中的小技巧,能大大方便我们的开发,持续更新. UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIV ...
- iOS小技巧 - 和屏幕等宽的Table分割线
前言 因为本人也是学习iOS才一个多月,在写程序的过程中经常会遇到一些看似应该很简单,但是要解决好却要知道一点小trick的问题. 因此后面会陆续记一些这类问题,一来加深印象,二来也可以做个备忘录. ...
- iOS小技巧:用runtime 解决UIButton 重复点击问题
http://www.cocoachina.com/ios/20150911/13260.html 作者:uxyheaven 授权本站转载. 什么是这个问题 我们的按钮是点击一次响应一次, 即使频繁的 ...
- iOS小技巧3
将颜色合成图片 将颜色合成图片 +(UIImage *)imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f, 1 ...
- 总有你需要的之 ios 小技巧 (下)
图片上绘制文字 写一个UIImage的category NSMutableParagraphStyle* paragraphStyle = [[NSParagraphStyle defaultPara ...
- IOS小技巧——使用FMDB时如何把一个对像中的NSArray数组属性存到表中
http://blog.csdn.net/github_29614995/article/details/46797917 在开发的当中,往往碰到要将数据持久化的时候用到FMDB,但是碰到模型中的属性 ...
- 你想要的iOS 小技巧总结
UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(, , ...
- IOS小技巧整理
1 随机数的使用 头文件的引用 #import <time.h> #import <mach/mach_time.h> srandom()的使用 ...
- <iOS小技巧> 昵称格式判断
一.使用方式 + 如下代码块功能:判断字体,判断字体输入格式 NSString *firstStr = [name substringToIndex:1]; NSArray *num ...
随机推荐
- HTTP 笔记与总结(2 )HTTP 协议的(请求行的)请求方法 及 (响应行的)状态码
(请求行的)请求方法 包括: GET,POST,HEAD,PUT,TRACE,DELETE,OPTIONS 注意:这些请求方法虽然是 HTTP 协议规定的,但是 Web Server 未必允许或支持这 ...
- 实现LoadRunner多个场景的顺序执行(命令行)
应用场景:假设有3个不同的测试场景,分别为并发登录.核心业务.可靠性测试,3个场景有先后执行顺序.由于白天测试机器另有用处,只能在晚上进行性能测试,这时我们的期望是能否把测试场景都设定好之后晚上自动运 ...
- oracle管理控制台不能打开,提示此网站的安全证书有问题?
在命令行里直接键入:certutil -setreg chain\minRSAPubKeyBitLength 128 然后再用IE打开.
- 【转】Unity LayerMask 的位运算
Unity的Layer Unity是用 int32来表示32个Layer层,int32用二进制来表示一共有32位. 0000 0000 0000 0000 0000 0000 0000 0000 31 ...
- spm完成dmp在windows系统上导入详细过程
--查询dmp字符集 cat spmprd_20151030.dmp ','xxxx')) from dual; spm完成dmp在windows系统上导入详细过程 create tablespace ...
- hibernate manytoone中的lazy EAGER
Hibernate中的字段映射中的Fetch有两种方式:EAGER和LAZY Eager:全部抓取 Lazy:延迟抓取 如果在字段中声明为Eager,那么在取得当前Bean时,同时会抓取Bean中的关 ...
- NDK编译FreeImage
参考了 以下2篇文章 并作了一小点修改 http://recursify.com/blog/2013/05/25/building-freeimage-for-android http://blog. ...
- Linux最常用命令及快捷键整理
最近在学Linux系统命令,在阿里云买了一台linux服务器.为方便自己也方便他人,整理了Linux常用命令及快捷键. 用命令: 文件和目录: # cd /home ...
- 20145211 《Java程序设计》课程总结——桃花流水窅然去
每周读书笔记链接汇总 20145211 <Java程序设计>第1周学习总结--小荷才露尖尖角 20145211 <Java程序设计>第2周学习总结--桃花依旧笑春风 20145 ...
- mysql存储过程之游标遍历数据表
原文:mysql存储过程之游标遍历数据表 今天写一个mysql存储过程,根据自己的需求要遍历一个数据表,因为对存储过程用的不多,语法不甚熟悉,加之存储过程没有调试环境,花了不少时间才慢慢弄好,故留个痕 ...