ios UIButton常用开发指南

一、字体颜色

设置UIButton上字体的颜色,不是用:

[payWayButton.titleLabel setTextColor:[UIColorblackColor]];

而是用:

[payWayButtonsetTitleColor:[UIColorblackColor]forState:UIControlStateNormal];

二、边框颜色

// 边框颜色

    [btn.layer setMasksToBounds:YES];

    [btn.layer setCornerRadius:0.0]; //设置矩圆角半径 8.0 就是个圆角了,这里是直角

    [btn.layer setBorderWidth:1.0];   //边框宽度

    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 1, 0, 0, 1 });

    [btn.layer setBorderColor:colorref]; //边框颜色

ios uiview开发汇总

一,拿一张图做view的背景

UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:@"image.png"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

self.view.backgroundColor = [UIColor colorWithPatternImage:image];

ios tableview开发汇总

一,下拉刷新

uirefreshcontrol-demo

1:

refreshControl = [[UIRefreshControl alloc] init];
refreshControl.backgroundColor = [UIColor purpleColor];
refreshControl.tintColor = [UIColor whiteColor];
[refreshControl addTarget:self
action:@selector(getLatestData)
forControlEvents:UIControlEventValueChanged];

[taskListView addSubview:refreshControl];

2:

-(void)getLatestData{
[self refreshStream];

}

 

3:

在  [self refreshStream]方法里面获取数据,刷新表格。截取最后部分reloadData方法后调用refreshControl

// Reload the table
[taskListView reloadData];

CGFloat tableHeight = [taskArray count] * 420.0f;
[taskListView setContentSize:CGSizeMake(taskListView.contentSize.width, tableHeight)];

NSLog(@”我的搭配需求list调用完毕”);

// End the refreshing
if (refreshControl) {

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@”MMM d, h:mm a”];
NSString *title = [NSString stringWithFormat:@”Last update: %@”, [formatter stringFromDate:[NSDate date]]];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:[UIColor whiteColor]
forKey:NSForegroundColorAttributeName];
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attrsDictionary];
refreshControl.attributedTitle = attributedTitle;

[refreshControl endRefreshing];
}

 

二、点击cell时显示的颜色

cell.selectionStyle = UITableViewCellSelectionStyleNone;不变

三、cell 需要定义自己的cell类,不然在view controller里不能定义变量进行关联。会显示repeat连接一个组件。

ios tabbar开发总结

UIStoryboard *storyboard;

storyboard = [UIStoryboard storyboardWithName:@”Main” bundle:nil];

UITabBarController * myScreen = (UITabBarController *)[storyboard instantiateViewControllerWithIdentifier:@”TabBar”];

myScreen.tabBar.tintColor=UIColorFromRGB(0xec083c);
//[self.tabBarController.tabBarsetSelectedImageTintColor:[UIColor greenColor]]; 说是ios7.1的

[self.window setRootViewController:myScreen];

// 第一颜色

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

 

//隐藏在页面最底下的tabbar

matchViewController.hidesBottomBarWhenPushed = YES;//隐藏tabbar

ios导航条开发汇总

1,背景颜色

2,

// 设置导航按钮
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc]
initWithTitle:@”账户”
style:UIBarButtonItemStylePlain
target:self
action:@selector(btnAccoutTapped:)];
UIBarButtonItem *leftButton2 = [[UIBarButtonItem alloc]
initWithTitle:@”搭配师”
style:UIBarButtonItemStylePlain
target:self
action:@selector(btnProfTapped:)];

self.navigationItem.leftBarButtonItems = @[leftButton,leftButton2];
self.navigationItem.title = @”任务列表”;

 

3

改变导航条背景颜色(ios8)

self.navigationController.navigationBar.barTintColor = [UIColor blueColor];

改变导航条按钮字体颜色

self.navigationController.navigationBar.tintColor = [UIColor purpleColor];

设置导航条标题字体大小和颜色

[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],
NSForegroundColorAttributeName:[UIColor redColor]}];

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

改变状态条颜色为白色

1在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO
2 在需要改变状态栏颜色的ViewController中在ViewDidLoad方法中增加:
[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

如果需要在全部View中都变色,可以写在父类的相关方法中,或者写到AppDelegate中。