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 ...
随机推荐
- [转]用Linq取CheckBoxList選取項目的值
本文转自:http://www.dotblogs.com.tw/hatelove/archive/2011/11/17/linq-checkboxlist-items-selected-values. ...
- java的Arrays工具类实战
java.util.Arrays类能方便地操作数组,它提供的所有方法都是静态的.静态方法是属于类的,不是属于类的对象.所以可以直接使用类名加方法名进行调用.Arrays作为一个工具类,能很好的操作数组 ...
- 插入随机数到MySQL数据库
我们经常会遇到使用随机的问题,下面就是一种解决随机数的方法. 在构造测试数据时,我们需要对测试表插入随机数据.构造测试数据的方法如下,仅以update为例说明 步骤1:随机数的SQL函数为rand() ...
- NBOJv2 Problem 1009 蛤玮的魔法(二分)
Problem 1009: 蛤玮的魔法 Time Limits: 1000 MS Memory Limits: 65536 KB 64-bit interger IO format: %ll ...
- VFS
VFS的作用:为文件系统提供通用的接口. 通用文件模型:common file model.特殊文件系统需要将它的物理结构转换成通用文件模型. common file model包括以下几个重要对象: ...
- OpenGL EXT: shader_buffer_load
http://www.opengl.org/registry/specs/NV/shader_buffer_load.txt Overview At a very coarse level, GL h ...
- 正则匹配中文.PHP不兼容的问题
不使用: ^[\u4e00-\u9fa5_a-zA-Z0-9_]+$ 有可能兼容有问题 if(!preg_match_all("/^[\\x7f-\\xff_a-zA-Z0-9]+$/&qu ...
- Android 通过网页打开自己的APP(scheme)
Android 通过网页打开自己的APP(scheme) 分类: android2014-07-09 17:35 8565人阅读 评论(2) 收藏 举报 通过用手机的浏览器(内置,第三方都可)访问一个 ...
- quanpailie quanbianli
#include<stdio.h>char data[5]={'a','b','c','d','e'};int vist[5]={0};char step[5]={0};char bu[5 ...
- Web Storage事件无法触发
不管是在同源其他页面还是在本页面都不能触发storage事件. <!DOCTYPE html> <html> <head> <meta charset=&qu ...