UI设计中的各种小控件

xib支持图形化操作,提供了几乎所有的控件可供选择,只需拖动到相应的位置即可,但是控件的后台代码仍然需要手动编写,一定程度上加速了前台的开发.

 

xib快速开发程序,手写代码速度比较慢

xib适合做静态页面,代码适合动态复杂的页面

xib不适合svn/git代码管理,代码比较适合

xib不适合后期维护,代码适合长期维护

 

如果xib文件名与类所在的文件夹名相同,可以直接使用init方法,自动查找同名的xib资源文件 

 

 

UISwitch 开关

 

设置显示时的开关状态

[mySwitch setOn:YES];

 

设置开状态的颜色

mySwitch.onTintColor=[UIColor redColor];

 

设置关状态的颜色

mySwitch.tintColor=[UIColor redColor];

 

开关中间的按钮的颜色

mySwitch.thumbTintColor=[UIColor yellowColor];

 

UIActivityIndicatorView 活动指示器(加载东西时出现的状态显示控件)

 

默认为YES,YES表示隐藏

activityIndicator.hidden=NO;

 

UISlider 滑动条

 

设置滑动条最小值

mySlider.minimumValue=1;

 

设置进度条的最大值

mySlider.maximumValue=10;

 

设置进度条按钮的背景颜色

mySlider.thumbTintColor=[UiColor redColor];

 

左侧滑动条的颜色

mySlider.minimumTrackTintColor=[UIColor blueColor];

 

右侧滑动条的颜色

mySlider.maximumTrackTintColor=[UIColor yellowColor];

 

UIStepper 增减按钮

 

最小减到的值

stepper.minimumValue=0;

 

最大增加到的值

stepper.maximumValue=1;

 

每次改变的值,每次加减0.2

stepper.stepValue=0.2;

 

UIProgressView 进度条

 

设置进度的位置为0

progressView.progress=0;

 

 

完成进度的进度条颜色

progressView.trackTintColor=[UIColor redColor];

 

未完成的进度条颜色

progressView.progressTintColor=[UIColor greenColor]; 

 

UIDatePicker 日历

 

显示日期模式(还有钟点模式,日期加钟点模式)

picker.datePickerModeDate=UIDatePickerModeDate;

 

NSDate 日期

 

设置最大日期

NSDate nowDate=[NSDate date];

NSDate maxDate=[nowDate dateByAddingTimeInterval:3600*24*30]; 

picker.maximumDate=maxDate;

 

UIAlertView对话框

 

设置弹出对话框的内容

UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"提示" message:@"你确定要删除吗?" delegate:nil cancelButtonTitle:@"否" otherButtonTitles:@"是", nil];

 

设置抬出对话框的模式

alertView.alertViewStyle=UIAlertViewStyleLoginAndPasswordInput;

 

设置对话框显示出来,若未设置,将不会显示

[alertView show];

 

UIActionSheet从手机下方推出的操作选择列表

 

设置显示推出框,不设置将不会推出

UIActionSheet *sheet=[[UIActionSheet alloc] initWithTitle:@"操作" delegate:self cancelButtonTitle:@"保存到手机" destructiveButtonTitle:@"发送给好友" otherButtonTitles:@"其他共享", nil];设置推出框的内容

    sheet.actionSheetStyle=UIActionSheetStyleAutomatic;推出框的模式

    [sheet showInView:self.view];

 

NSTimer 计时器

 

设置计时器每隔一秒触发一次事件,调用本类中的方法并重复调用

_timer=[NSTimer scheduledTimerWithTimeInterval:1 target: self selector: @selector(updateLabel:) userInfo:nil repeats:YES];

 

 NSTimer *timer;

    //暂停计时器(在很久以后再开始)

    [timer setFireDate:[NSDate distantFuture]];

    //重启计时器(从当前按时刻开始)

    [timer setFireDate:[NSDate date]];    //或者(从过去时刻开始)[timer setFireDate:[NSDate distantPast]];

    //毁掉计时器

    if([timer isValid])

    {

        [timer invalidate];

    }

 

转载于:https://www.cnblogs.com/PaulpauL/p/4935232.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值