Skip to content

Instantly share code, notes, and snippets.

//获取当前时间
- (NSString *)currentDateStr{
NSDate *currentDate = [NSDate date];//获取当前时间,日期
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];// 创建一个时间格式化对象
[dateFormatter setDateFormat:@"YYYY/MM/dd hh:mm:ss SS "];//设定时间格式,这里可以设置成自己需要的格式
NSString *dateString = [dateFormatter stringFromDate:currentDate];//将时间转化成字符串
return dateString;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[target performSelector:selector];
#pragma clang diagnostic pop
@qy1010
qy1010 / untitled
Last active January 8, 2020 11:59
+ (void)checkCameraPermission:(void(^)(BOOL status))block
{
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];//读取设备授权状态
if (authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) {
if (block) {
block(NO);
}
return;
}
else if (authStatus == AVAuthorizationStatusNotDetermined) {
//镂空效果
- (void)photoFadeout
{
UIView *backgroundView = [[UIView alloc] init];
backgroundView.frame = self.view.bounds;
backgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
[self.view addSubview:backgroundView];
// 创卷一个全屏大Path
- (void)addLineDashPattern:(UIView *)view
{
[view.layer.sublayers enumerateObjectsUsingBlock:^(__kindof CALayer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[obj removeFromSuperlayer];
obj = nil;
}];
view.layer.masksToBounds = YES;
view.layer.cornerRadius = view.frame.size.width / 2;
暂停:
[timer setFireDate:[NSDate distantFuture]];
继续:
[timer setFireDate:[NSDate date]];
@qy1010
qy1010 / ios
Created December 16, 2019 07:22
UIView *myView = [[UIView alloc] init];
myView.frame = CGRectMake(0, 0, 50, 50);
myView.backgroundColor = [UIColor blackColor];
[self.view addSubview:myView];
[UIView animateWithDuration:2.0 animations:^{
// 2 秒内向右移动 100, 向下移动100。
myView.transform = CGAffineTransformMakeTranslation(100, 100);
} completion:^(BOOL finished) {
电池电量 Prefs:root=BATTERY_USAGE
通用设置 Prefs:root=General
存储空间 Prefs:root=General&path=STORAGE_ICLOUD_USAGE/DEVICE_STORAGE
蜂窝数据 Prefs:root=MOBILE_DATA_SETTINGS_ID
Wi-Fi 设置 Prefs:root=WIFI
蓝牙设置 Prefs:root=Bluetooth
定位设置 Prefs:root=Privacy&path=LOCATION
辅助功能 Prefs:root=General&path=ACCESSIBILITY
关于手机 Prefs:root=General&path=About
键盘设置 Prefs:root=General&path=Keyboard
这个方法判断是否允许使用相册的回调
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if (status == PHAuthorizationStatusAuthorized) {
//允许使用相册
}else{
//不允许使用相册
}
}];
PHAuthorizationStatus photoAuthorStatus = [PHPhotoLibrary authorizationStatus];
#shell判断文件夹是否存在
#如果文件夹不存在,创建文件夹 // /myfolder 根目录下是否有myfolder
if [ ! -d "/myfolder" ]; then
mkdir /myfolder
fi
#shell判断文件,目录是否存在或者具有权限
folder="/var/www/"