<span style="font-family: Arial, Helvetica, sans-serif;">1.button的某个我喜欢的效果</span>
button.showsTouchWhenHighlighted = YES;
2.导航栏背景色、添加左右按键
[self.navigationItem setTitle:@"主关注"];
self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:search] autorelease];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:add] autorelease];
;
3.改变导航栏ITem颜色
1)自定义label,改变当前导航栏字体颜色
UILabel *navLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
navLable.text = @"主关注";
navLable.font = [UIFont systemFontOfSize:30];
navLable.backgroundColor = [UIColor clearColor];
navLable.textAlignment = 1;//字体居中
navLable.textColor = [UIColor colorWithRed:0.3 green:0.1 blue:0.05 alpha:0.8];
self.navigationItem.titleView = navLable;
[navLable release];</span>
2)非自定义,都适用
NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];
self.navigationController.navigationBar.titleTextAttributes = dic;
4.进入下一界面隐藏工具栏
按钮触发的点击事件,push到下一界面隐藏工具栏
- (void)addChartAction
{
SuccessChartViewController *chart = [[SuccessChartViewController alloc] init];
chart.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:chart animated:YES];
}
5.tableView 点击cell进入下一界面
//点击cell进入下一视图
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SuccessAddViewController *addView = [[SuccessAddViewController alloc] init];
addView.hidesBottomBarWhenPushed = YES;//进入后隐藏工具栏
[self.navigationController pushViewController:addView animated:YES];
}
6.系统cell字体大小的设置
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *pool = @"pool";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:pool];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pool"] autorelease];
}
[cell.textLabel setText:@"登录"];
cell.textLabel.font = [UIFont systemFontOfSize:30];
cell.textLabel.textAlignment = NSTextAlignmentCenter;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// cell.opaque = NO;
cell.textLabel.backgroundColor = [UIColor clearColor];
[cell setBackgroundColor:[UIColor colorWithRed:10/255.0 green:0.5 blue:1 alpha:0.1]];
return cell;
}
7.添加图片
UIImageView *lol = [[UIImageView alloc] initWithFrame:CGRectMake(70, 20, 200, 160)];
UIImage *image = [UIImage imageNamed:@"LL.jpg"];
[lol setImage:image];
[self.view addSubview:lol];
[lol release];
8.ARC与非ARC在一个项目中同时使用
1,选择项目中的Targets,选中你所要操作的Target,
2,选Build Phases,在其中Complie Sources中选择需要ARC的文件双击,并在输入框中输入:-fobjc-arc,如果不要ARC则输入:-fno-objc-arc。
9.用户交互开
UILabel 用户交互默认为NO,
.userInteractionEnabled = YES;
10.释放池
1)用于MRC和ARC
@autoreleasepool{
}
2)用于MRC
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
………………………………………………………………………………
[pool release];
UIColor *color = [UIColor blackColor];
textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSForegroundColorAttributeName: color}];
12.键盘的return 变成next或者done
[_name setReturnKeyType:UIReturnKeyNext];
13.popTo某个View
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
14.label适配问题(注意顺序)
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0)];
[label1 setText:@"召唤师名称"];
[label1 setNumberOfLines:0];
[label1 sizeToFit];//适配
[self.view addSubview:label1];
[label1 release];
15.label 和imageView设置圆形
_nameLable.layer.borderColor = [UIColor cyanColor].CGColor;
_nameLable.layer.borderWidth = 6;
_image.layer.masksToBounds = YES;
_image.layer.cornerRadius = 30;
_image.userInteractionEnabled = YES;
16.toolBar
self.doneToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 220, 320, 30)];
NSMutableArray *myToolBarItems = [NSMutableArray array];
[myToolBarItems addObject:[[[UIBarButtonItem alloc]
initWithTitle:@" 完成"
style:UIBarButtonItemStyleDone
target:self
action:@selector(selectButton:)] autorelease]];
[_doneToolbar setItems:myToolBarItems animated:YES];
[self.view addSubview:_doneToolbar];
[_doneToolbar release];
17.tableView滑动条的隐藏,颜色的改变
18.tableView cell的label 高度适配
//隐藏
self.tableView.showsVerticalScrollIndicator = NO;
//修改颜色
self.tableView.indicatorStyle=UIScrollViewIndicatorStyleWhite;
18.tableView cell的label 高度适配
for (NSDictionary * dic in arrays) {
NSString * str = [dic objectForKey:@"content"];
UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 285, 10)];
label.text = str;
CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:18] constrainedToSize:CGSizeMake(280, 6454) lineBreakMode:NSLineBreakByWordWrapping];
NSNumber * number = [NSNumber numberWithFloat:size.height];
[_heightArray addObject:number];
[label removeFromSuperview];
}
19.tableView协议
//-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
//{
// return [[_tableArray objectAtIndex:section] valueForKey:@"title"];
//
//}
20.在导航栏上设置图片按钮
//图片要设置成64一下 40,40
UIImage * im = [UIImage imageNamed:@"5.gif"];
//图片扁平化
UIImage * immm = [im imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem * right =[[UIBarButtonItem alloc]initWithImage:immm style:UIBarButtonItemStyleBordered target:self action:@selector(searchAction)];
self.navigationItem.rightBarButtonItem =right;
UIImage * lefimage =[UIImage imageNamed:@"1.png"];
UIImage * lefti =[lefimage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem * left =[[UIBarButtonItem alloc]initWithImage:lefti style:UIBarButtonItemStyleBordered target:self action:@selector(mainAction)];
self.navigationItem.leftBarButtonItem = left;
21.消息中心监听键盘
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector() name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector() name:UIKeyboardWillShowNotification object:nil];
// NSArray *arr = @[@111,@222,@111];
NSArray *arr = [NSArray arrayWithObjects:@"2",@"2",@"6", nil];
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
for (NSNumber *number in arr) {
[dic setObject:number forKey:number];
}
NSLog(@"%@",[dic allValues]);
NSArray *arr = @[@111,@222,@111];
NSSet *set = [NSSet setWithArray:arr];
NSLog(@"%@",[set allObjects]);