总结的一些简单实用的小方法
来源:互联网 发布:csm算法 编辑:程序博客网 时间:2024/06/07 00:38
1.self.navigationController.navigationBar.subviews[0].alpha = 0 设置导航栏为透明
3.点击cell上的按钮时,获取所在的cell
4.someview 显示一段时间后自动消失
[self performSelector:@selector(dismissView:) withObject:someview afterDelay:2];
if ([[UIDevice currentDevice] systemVersion].floatValue >= 5.0 ) { [self setBackgroundImage:[UIImage imageNamed:@"navBar"] forBarMetrics:UIBarMetricsDefault];
6.把导航条底部的横线去掉
[self.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
7.配合runtime,类别上是可以加属性的
objc_setAssociatedObject(self, @"string", string, OBJC_ASSOCIATION_COPY_NONATOMIC);
return objc_getAssociatedObject(self,@"string");
8.循环,遍历出数组
for (int i = 0; i < [titleStr length]; i++) {
int a = [titleStr characterAtIndex:i];
if (isdigit(a)) {
//让数字颜色改变
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(i, 1)];
}
}
//两行lable之间设置间距
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:20*SCALAE];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [titleStr length])];
9.自适应cell高度,可以返还CELL的高度(大概范围)
self.tableView.rowHeight = UITableViewAutomaticDimension
2. flashScrollIndicators
这个很有用,闪一下滚动条 ,暗示是否有可滚动的内容,可在ViewDidAppear [table reload] 之后调用
3.点击cell上的按钮时,获取所在的cell
-(void)OnTouchBtnInCell:(UIButton *)btn {
CGPoint point = btn.center;
point = [table convertPoint:point fromView:btn.superview];
NSIndexPath* indexpath = [table indexPathForRowAtPoint:point];
UITableViewCell *cell = [table cellForRowAtIndexPath:indexpath];
}
4.someview 显示一段时间后自动消失
[self performSelector:@selector(dismissView:) withObject:someview afterDelay:2];
5. UINavigationBar (selBackground)
if ([[UIDevice currentDevice] systemVersion].floatValue >= 5.0 ) { [self setBackgroundImage:[UIImage imageNamed:@"navBar"] forBarMetrics:UIBarMetricsDefault];
} else {
self.layer.contents = (id)[UIImage imageNamed:@"navBar"].CGImage;
}
}
6.把导航条底部的横线去掉
[self.navigationBar setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
7.配合runtime,类别上是可以加属性的
objc_setAssociatedObject(self, @"string", string, OBJC_ASSOCIATION_COPY_NONATOMIC);
return objc_getAssociatedObject(self,@"string");
8.循环,遍历出数组
for (int i = 0; i < [titleStr length]; i++) {
int a = [titleStr characterAtIndex:i];
if (isdigit(a)) {
//让数字颜色改变
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(i, 1)];
}
}
//两行lable之间设置间距
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:20*SCALAE];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [titleStr length])];
9.自适应cell高度,可以返还CELL的高度(大概范围)
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 100
1 0
- 总结的一些简单实用的小方法
- 简单实用控制血压的一些小方法
- asp.net的一些实用小方法
- iOS开发一些实用的小方法
- 自己总结的一些安卓的实用小技巧
- 一些实用的小模板
- jquery easyui combox一些实用的小方法
- 【转】一些令女生漂亮的小方法,很实用..........
- 简单实用的一些快捷键
- iOS开发中一些实用方法的总结
- UIGestureRecognizer的一些简单的方法总结
- 【Android】一些会用到的简单但使用的小方法总结
- Python实用的小方法
- 一些搜集的实用方法
- javaScript实用的一些方法
- QTreeWidget的一些实用方法
- JS一些实用的方法
- 一些实用的js方法
- bzoj 4176: Lucas的数论 (反演)
- Android Studio集成友盟APP统计
- ffmpeg日志回调添加
- 强化学习读书笔记
- nodeJS socket 多个房间的聊天室
- 总结的一些简单实用的小方法
- 初识Shiro
- Spring组合属性
- Android Matrix的用法总结
- Opencv的Kalman滤波器函数二
- 初识linux
- Java设计模式之策略模式
- 自定义控件--描边字体
- Syntax error, insert "EnumBody" to complete ClassBodyDeclarations