您的位置:首页 > 移动开发 > IOS开发

iOS 控件小句子,大技巧

2015-02-03 09:19 169 查看
有些时候一些效果只要一个句子就解决了,但是往往搜索半天,今天小编准备慢慢在学习路上遇到的都积累起来,随时更新


1.取消回弹
self.tableview.bounces =NO;

2.取消滚动条显示

self.tableView.showsVerticalScrollIndicator =NO;

3.去掉cell的分割线

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];



_tableview.separatorStyle =UITableViewCellSeparatorStyleNone;

4.设置圆角

_big_view.layer.cornerRadius =8.0f;

[_big_view.layersetMasksToBounds:YES];

5.将图片设置为背景

self.view.backgroundColor
= [UIColorcolorWithPatternImage:[UIImageimageNamed:@"底板.jpg"]];

6. 设置tableview的背景图片

UIImageView * view = [[UIImageViewalloc]init];

view.backgroundColor = [UIColorcolorWithPatternImage:[UIImageimageNamed:@"底板.jpg"]];

self.tableview.backgroundView = view;

7.将数组里的元素取出来,强转化成字典类型(当确定为字典类型时)

NSDictionary * dic = (NSDictionary *)[dataobjectAtIndex:[datacount] - indexPath.row];

8.去掉导航条(UINavigationbar)自带“Back”字样

UIBarButtonItem *returnButtonItem
= [[UIBarButtonItemalloc]init];
returnButtonItem.title =@"";(此处也可更改)
returnButtonItem.tintColor = [UIColor redColor];

self.navigationItem.backBarButtonItem = returnButtonItem;

9.改变导航条(UINavigationbar)自带返回箭头的颜色

self.navigationController.navigationBar.tintColor
= [UIColorblackColor];

10.UITextField 删除文本框效果(右侧有个叉按钮)

UITextField * field = [[UITextFieldalloc]init];

field.delegate =self;

field.frame =CGRectMake(20,20,280,30);

field.clearsOnBeginEditing =YES;

field.clearButtonMode =UITextFieldViewModeNever;//从不删除字符

field2.clearButtonMode =UITextFieldViewModeWhileEditing;//处于编辑状态才可删除字符

field3.clearButtonMode =UITextFieldViewModeUnlessEditing;//非编辑状态才可删除字符

field4.clearButtonMode =UITextFieldViewModeAlways;//总是可以删除字符

field.autocapitalizationType =
UITextAutocapitalizationTypeNone;

field.returnKeyType =
UIReturnKeyDone;

field.clearButtonMode =
UITextFieldViewModeWhileEditing; //编辑时会出现个修改X

field.contentVerticalAlignment =
UIControlContentVerticalAlignmentCenter;//垂直居中

field.borderStyle =
UITextBorderStyleRoundedRect;//圆角
11.取消滚动条

_home_collection.showsHorizontalScrollIndicator =NO;

12.改变导航条字体颜色

self.navigationItem.title =@"首页";

//改变导航条字体颜色

self.navigationController.navigationBar.titleTextAttributes
= [NSDictionarydictionaryWithObject:[UIColorwhiteColor]forKey:NSForegroundColorAttributeName];
13.当ScrollView 无法滑动

//设置回弹即可滑动

_images.alwaysBounceVertical =YES;

_images.userInteractionEnabled =YES;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: