#####设置按钮点击前后的显示图片
[_playbtn setImage:[UIImage imageNamed:@“btn_play@2x.png”] forState:UIControlStateNormal];
[_playbtn setImage:[UIImage imageNamed:@“btn_pause@2x.png”] forState:UIControlStateSelected];
#####设置导航条上的字体大小和颜色
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]}];
设置组头高度的方法
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.1;
}
去掉单元格后的灰色点击选中效果
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self.tableview deselectRowAtIndexPath:indexPath animated:NO];
}
动画条
UILabel * textView = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 30)];
textView.text = @“八十多分卡是经典款拉屎的法师打发”;
[self.view addSubview:textView];
[UIView animateWithDuration:3 delay:2 options:UIViewAnimationOptionRepeat animations:^{
//怎样的动画
textView.frame = CGRectMake(-self.view.frame.size.width, 100,self.view.frame.size.width , 30);
} completion:^(BOOL finished) {
NSLog(@"动画结束");
}];
//获取plist 文件里的数据,并封装为Model 存放到数据源里
NSString * path = [[NSBundle mainBundle]pathForResource:@“Property List” ofType:@“plist”];
NSMutableArray * array =[NSMutableArray arrayWithContentsOfFile:path];
###
// 默认为关闭大标题模式--标题变化--上滑变小并置顶
self.navigationController.navigationBar.prefersLargeTitles = YES;
###
//搜索条
UISearchBar *ser=[[UISearchBar alloc]initWithFrame:CGRectMake(30, 170, 400, 40)];
ser.placeholder=@“搜索”;
//设置搜索条里面的背景色
UITextField *searchField = [ser valueForKey:@“searchField”];
searchField.backgroundColor = [UIColor colorWithRed:230/256.0 green:230/256.0 blue:231/256.0 alpha:1.0];
//给搜索条添加个图片设置为空 背景就成了白色了
[ser setBackgroundImage:[UIImage new]];
//将搜索条添加到头视图中
self.tableview.tableHeaderView=ser;
启动图片停留时间–10秒
[NSThread sleepForTimeInterval:10.0];
###单元格分割线颜色设置

######设置标签控制器tabbar为透明:
//覆盖原生Tabbar的上横线
// [[UITabBar appearance] setShadowImage:[self createImageWithColor:[UIColor clearColor]]];
//背景图片为透明色
// [[UITabBar appearance] setBackgroundImage:[self createImageWithColor:[UIColor clearColor]]];
self.tabBar.backgroundColor = [UIColor clearColor];
//设置为半透明
self.tabBarController.tabBar.translucent = YES;
-(UIImage*) createImageWithColor:(UIColor*) color
{
CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
########让UILabel在指定的地方换行
// 换行符为\n,在需要换行的地方加上这个符号即可,
如 label.numberOfLines =0;
label.text = @“此处\n换行”;
######### ios修改textField的placeholder的字体颜色、大小
textField.placeholder = @“username is in here!”;
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
//设置输入字体的颜色
tf.textColor=[UIColor lightGrayColor];
###########
//判断是否为第一次启动,若为第一次启动则执行引导页
if (![[NSUserDefaults standardUserDefaults] boolForKey:@“everLaunched”]) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@“everLaunched”];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@“firstLaunch”];
NSLog(@“first launch第一次程序启动”);
//这里进入引导画面
self.window.rootViewController=[[GDViewController alloc] init];
}else {
NSLog(@“second launch再次程序启动”);
////直接进入主界面
self.window.rootViewController=[[ViewController alloc] init];
}
##########设置按钮勾选☑️状态
UIButton *checkbox = [UIButton buttonWithType:UIButtonTypeCustom];
// checkbox.backgroundColor = [UIColor redColor];
CGRect checkboxRect = CGRectMake(135,150,36,36);
[checkbox setFrame:checkboxRect];
[checkbox setImage:[UIImage imageNamed:@"cb_glossy_off"] forState:UIControlStateNormal];
[checkbox setImage:[UIImage imageNamed:@"cb_glossy_on"] forState:UIControlStateSelected];
[checkbox addTarget:self action:@selector(checkboxClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:checkbox];
}
-(void)checkboxClick:(UIButton *)btn
{
btn.selected = !btn.selected;
}
############
//设置视图的背景透明度
view.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0];
这篇博客分享了在iOS编程中实现各种界面效果和交互的代码示例,包括设置按钮点击前后图片、导航条字体样式、去除表格选中效果、自定义搜索条、标签控制器透明效果、UILabel换行、UITextField占位符样式调整以及视图透明度控制等实用技巧。

被折叠的 条评论
为什么被折叠?



