登录 立即注册
金钱:

Code4App-iOS开发-iOS 开源代码库-iOS代码实例搜索-iOS特效示例-iOS代码例子下载-Code4App.com

时间选择器

[复制链接]
来自: 天天开心就好 分类: iOS精品源码 上传时间: 2016-7-25 15:24:36
Tag:datePicker picker 时间选择器 date 日期

项目介绍:

UIPikerView时间选择器,自定义控件,选中颜色变化,取消和确定选中时间。开始进入选择器选中时间等操作!代理方法和控件代理及可实现   

主要集成代码如下:

[Objective-C] 查看源文件 复制代码
#import "ViewController.h"
#import "XMRTimePiker.h"
#define selfBacground [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1.0]
#define selfHeight [UIScreen mainScreen].bounds.size.height
@interface ViewController ()<XMRTimePikerDelegate>{

    UIButton * _time_button;
    
    NSString * _time;

}

@end

@implementation ViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    // Do any additional setup after loading the view, typically from a nib.
    
    UIButton * button=[UIButton buttonWithType:UIButtonTypeSystem];
    
    self.view.backgroundColor=selfBacground;
    
    button.frame=CGRectMake(0,selfHeight-109,320, 50);
        
    [button setTitle:@"点击" forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:button];
    
    
     _time_button=[UIButton buttonWithType:UIButtonTypeSystem];
    
    _time_button.backgroundColor=[UIColor greenColor];
    
    [_time_button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    _time_button.frame=CGRectMake(0,selfHeight-159,320, 50);
    
    [_time_button addTarget:self action:@selector(Timeclick:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:_time_button];
    
}
-(void)click{
    
    XMRTimePiker *piker=[[XMRTimePiker alloc]init];
    
    piker.delegate=self;
    
    [piker showTime];
    
}
-(void)XMSelectTimesViewSetOneLeft:(NSString *)oneLeft andOneRight:(NSString *)oneRight andTowLeft:(NSString *)towLeft andTowRight:(NSString *)towRight{

    _time=[NSString stringWithFormat:@"%@:%@-%@:%@",oneLeft,oneRight,towLeft,towRight];
    
    [_time_button setTitle:_time forState:UIControlStateNormal];

}
-(void)Timeclick:(UIButton*)bnt{
    
    if (_time.length!=0) {
        
        NSArray * text_arr=[_time componentsSeparatedByString:@"-"];
        NSString * star_str=text_arr[0];
        NSString * end_str=text_arr[1];
        NSArray * star_arr=[star_str componentsSeparatedByString:@":"];
        NSArray * end_arr=[end_str componentsSeparatedByString:@":"];
        
        XMRTimePiker *timeView = [[XMRTimePiker alloc] init];
        timeView.delegate = self;
        [timeView SetOldShowTimeOneLeft:star_arr[0] andOneRight:star_arr[1] andTowLeft:end_arr[0] andTowRight:end_arr[1]];
        [timeView showTime];
    }
  
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end


DEMO 直接下载: 时间选择器.zip (73.47 KB, 下载次数: 331, 售价: 10 金钱)

2545 1 0
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542


代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| 广东互联网违法和不良信息举报中心|中国互联网举报中心|Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表