54 lines
1.5 KiB
Objective-C
54 lines
1.5 KiB
Objective-C
//
|
|
// LYSDateBasicViewController.m
|
|
// LYSDatePickerController
|
|
//
|
|
// Created by HENAN on 2018/5/7.
|
|
// Copyright © 2018年 liyangshuai. All rights reserved.
|
|
//
|
|
|
|
#import "LYSDateBasicViewController.h"
|
|
|
|
@interface LYSDateBasicViewController ()
|
|
|
|
@end
|
|
|
|
@implementation LYSDateBasicViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
// 获取最外层控制器
|
|
+ (UIViewController *)windowRootViewController
|
|
{
|
|
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
|
return keyWindow.rootViewController;
|
|
}
|
|
// 创建给定颜色和透明度的图片
|
|
- (UIImage *)imageWithColor:(UIColor *)color alpha:(CGFloat)alpha
|
|
{
|
|
// 创建一个color对象
|
|
UIColor *tempColor = [color colorWithAlphaComponent:alpha];
|
|
// 声明一个绘制大小
|
|
CGSize colorSize = CGSizeMake(1, 1);
|
|
UIGraphicsBeginImageContext(colorSize);
|
|
// 开始绘制颜色区域
|
|
CGContextRef context = UIGraphicsGetCurrentContext();
|
|
// 根据提供的颜色给相应绘制内容填充
|
|
CGContextSetFillColorWithColor(context, tempColor.CGColor);
|
|
// 设置填充相应的区域
|
|
CGContextFillRect(context, CGRectMake(0, 0, 1, 1));
|
|
// 声明UIImage对象
|
|
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
|
|
UIGraphicsEndImageContext();
|
|
return img;
|
|
}
|
|
|
|
@end
|