码迷,mamicode.com
首页 > 其他好文 > 详细

UI设计中的各种小控件

时间:2015-11-04 11:13:46      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:

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];

    }

 

UI设计中的各种小控件

标签:

原文地址:http://www.cnblogs.com/PaulpauL/p/4935232.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!