博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UIDatePicker自定义背景
阅读量:5280 次
发布时间:2019-06-14

本文共 2441 字,大约阅读时间需要 8 分钟。

    selectDatePicker = [[UIDatePicker alloc]init];

    selectDatePicker.frame = CGRectMake(0, 10, 280, 216);
    selectDatePicker.tag = 8001;
    selectDatePicker.datePickerMode = UIDatePickerModeDate;
    selectDatePicker.backgroundColor = [UIColor clearColor];
    
    
    //改背景色===================================================================
    UIView *v = [[selectDatePicker subviews] objectAtIndex:0];
    
    //改变最外层的背景
    UIView *v0 = [[v subviews] objectAtIndex:0 ];
    v0.backgroundColor = [Function colorWithHexString:@"#f5f5f5"];
    //去掉最大的框
    UIView *v20 = [[v subviews] objectAtIndex:20];
    v20.alpha = 0.0;
    
    //第一列的设置--------------------------------
    UIView *v1 = [[v subviews] objectAtIndex:1 ];
    v1.alpha = 0.6;
    UIView *v2 = [[v subviews] objectAtIndex:2 ];
    v2.alpha = 0;
    UIView *v3 = [[v subviews] objectAtIndex:3 ];
    v3.alpha = 0;
    UIView *v4 = [[v subviews] objectAtIndex:4 ];
    v4.backgroundColor = [Function colorWithHexString:@"#eae1d8"];
    UIView *v5 = [[v subviews] objectAtIndex:5 ];
    v5.alpha = 0.0;
    UIView *v6 = [[v subviews] objectAtIndex:6 ];
    v6.alpha=0.6;
    
    //第二列的设置--------------------------------
    UIView *v7 = [[v subviews] objectAtIndex:7 ];
    v7.alpha = 0.6;
    UIView *v8 = [[v subviews] objectAtIndex:8 ];
    v8.alpha = 0;
    UIView *v9 = [[v subviews] objectAtIndex:9 ];
    v9.alpha = 0;
    UIView *v10 = [[v subviews] objectAtIndex:10 ];
    v10.backgroundColor = [Function colorWithHexString:@"#eae1d8"];
    UIView *v11 = [[v subviews] objectAtIndex:11 ];
    v11.alpha = 0.0;
    UIView *v12 = [[v subviews] objectAtIndex:12 ];
    v12.alpha=0.6;
    
    //第三列的设置--------------------------------
    UIView *v13 = [[v subviews] objectAtIndex:13 ];
    v13.alpha = 0.6;
    UIView *v14 = [[v subviews] objectAtIndex:14 ];
    v14.alpha = 0;
    UIView *v15 = [[v subviews] objectAtIndex:15 ];
    v15.alpha = 0;
    UIView *v16 = [[v subviews] objectAtIndex:16 ];
    v16.backgroundColor = [Function colorWithHexString:@"#eae1d8"];
    UIView *v17 = [[v subviews] objectAtIndex:17 ];
    v17.alpha = 0.0;
    UIView *v18 = [[v subviews] objectAtIndex:18 ];
    v18.alpha=0.6;
    
    UIView *v19 = [[v subviews] objectAtIndex:19 ];
    v19.alpha=0.0;
    //改背景色End===================================================================
    
    
    
    
    //设置为指定时间
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-M-d"]; //设置日期格式
    NSString *date = @"2010-10-1";
    NSDate *now = [dateFormatter dateFromString:date];
    
    
    [selectDatePicker setDate:now animated:NO];
    [viewContent addSubview:selectDatePicker];

转载于:https://www.cnblogs.com/lear/p/3213988.html

你可能感兴趣的文章
ES6扩展运算符(三点运算符)...的用法
查看>>
利用maven 下依赖包
查看>>
POJ 3616 Milking Time
查看>>
Cocos2d-x ios 下http请求的另一种实现
查看>>
【JEMTER】后置处理器JSON Path Extractor获取server端返回的json中某项值
查看>>
Server.MapPath()
查看>>
LeetCode(13):罗马数字转整数
查看>>
chrome 开发者工具 paused in debugger
查看>>
Javascript中的类实现
查看>>
Swift 的类、结构体、枚举等的构造过程Initialization(下)
查看>>
温故而知新--JavaScript书摘(三)
查看>>
LeaFlet中切片图层使用自定义坐标系
查看>>
docker安装升级linux内核(2.6.32->3.12.17)
查看>>
JavaScript原型链memo
查看>>
springboot 中使用事务
查看>>
jquery 获取table当前行值
查看>>
Linux网络配置之虚拟网卡的配置(ubuntu 16.04)
查看>>
django之允许外部机器访问
查看>>
关于C#中接口的概念
查看>>
在bochs上运行的第一个操作系统
查看>>