这段代码是实现了类似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的更多相关文章

  1. iOS小技巧总结,绝对有你想要的

    原文链接 在这里总结一些iOS开发中的小技巧,能大大方便我们的开发,持续更新. UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIV ...

  2. iOS小技巧 - 和屏幕等宽的Table分割线

    前言 因为本人也是学习iOS才一个多月,在写程序的过程中经常会遇到一些看似应该很简单,但是要解决好却要知道一点小trick的问题. 因此后面会陆续记一些这类问题,一来加深印象,二来也可以做个备忘录. ...

  3. iOS小技巧:用runtime 解决UIButton 重复点击问题

    http://www.cocoachina.com/ios/20150911/13260.html 作者:uxyheaven 授权本站转载. 什么是这个问题 我们的按钮是点击一次响应一次, 即使频繁的 ...

  4. iOS小技巧3

    将颜色合成图片 将颜色合成图片 +(UIImage *)imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f, 1 ...

  5. 总有你需要的之 ios 小技巧 (下)

    图片上绘制文字 写一个UIImage的category NSMutableParagraphStyle* paragraphStyle = [[NSParagraphStyle defaultPara ...

  6. IOS小技巧——使用FMDB时如何把一个对像中的NSArray数组属性存到表中

    http://blog.csdn.net/github_29614995/article/details/46797917 在开发的当中,往往碰到要将数据持久化的时候用到FMDB,但是碰到模型中的属性 ...

  7. 你想要的iOS 小技巧总结

    UITableView的Group样式下顶部空白处理 //分组列表头部空白处理 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(, , ...

  8. IOS小技巧整理

    1 随机数的使用  头文件的引用         #import <time.h>        #import <mach/mach_time.h> srandom()的使用 ...

  9. <iOS小技巧> 昵称格式判断

    一.使用方式 + 如下代码块功能:判断字体,判断字体输入格式       NSString *firstStr = [name substringToIndex:1];    NSArray *num ...

随机推荐

  1. Leetcode | Parentheses 相关

    Generate Parentheses Given n pairs of parentheses, write a function to generate all combinations of ...

  2. MS14-025引起的问题 - 2

    5月,微软在13日发布月度安全更新,其中 有KB2871997和 KB2928120两个知识库文章Knowledgeased(而KB2871997甚至不是Security Bulletin).对于无论 ...

  3. PHP+jQuery 注册模块的改进之一:验证码存入SESSION

    /* ******* Date:2014-09-28 ******* Author:小dee ******* Blog:http://www.cnblogs.com/dee0912/*/ 对上一篇博文 ...

  4. 升级xcode6和ios8后,unity遇到的一些小问题

    升级最新的Xocde6后,如果不是最新版本的unity,虽然也可以也可以正常的build,但如果想通过unity连真机进行profile的话,就会在xocde中报错,这个的主要原因是unity的配置里 ...

  5. PHP 魔术变量

    PHP 魔术变量 PHP 向它运行的任何脚本提供了大量的预定义常量. 不过很多常量都是由不同的扩展库定义的,只有在加载了这些扩展库时才会出现,或者动态加载后,或者在编译时已经包括进去了. 有八个魔术常 ...

  6. 随机(Random)

    随机(Random)随机是智能的基础,人工智能的很多技术都需要用到随机,因此有必要把这个提到前面谈谈一考虑基于C/C++,般我们都是使用的rand ()等函数实现随机,当然我们也有吊炸天的boost库 ...

  7. Advanced Packaging Tool

    https://en.wikipedia.org/wiki/Advanced_Packaging_Tool Eventually, a new team picked up the project, ...

  8. linux C gcc -lm

    使用math.h中声明的库函数还有一点特殊之处,gcc命令行必须加-lm选项,因为数学函数位于libm.so库文件中(这些库文件通常位于/lib目录下),-lm选项告诉编译器,我们程序中用到的数学函数 ...

  9. WIN10 ANDROIDSTUDIO1.2 安装完首次启动报错

    环境 ACER NOTEBOOK  WIN10 ANNDROID 1.2 解决方案: 在Android Studio安装目录下的 bin 目录下,找到 idea.properties 文件,在文件最后 ...

  10. 初入C的世界

    大家好,我叫吉贯之,来自贵州省遵义市,现就读于北京工业大学耿丹学院信息技术系计算机与科学专业,我的学号是160809127,我喜欢运动和一些电脑方面的软件操作. 应老师要求在博客园建立的博客,地址是h ...