This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//获取当前时间 | |
- (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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
[target performSelector:selector]; | |
#pragma clang diagnostic pop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//镂空效果 | |
- (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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
暂停: | |
[timer setFireDate:[NSDate distantFuture]]; | |
继续: | |
[timer setFireDate:[NSDate date]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
电池电量 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
这个方法判断是否允许使用相册的回调 | |
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { | |
if (status == PHAuthorizationStatusAuthorized) { | |
//允许使用相册 | |
}else{ | |
//不允许使用相册 | |
} | |
}]; | |
PHAuthorizationStatus photoAuthorStatus = [PHPhotoLibrary authorizationStatus]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#shell判断文件夹是否存在 | |
#如果文件夹不存在,创建文件夹 // /myfolder 根目录下是否有myfolder | |
if [ ! -d "/myfolder" ]; then | |
mkdir /myfolder | |
fi | |
#shell判断文件,目录是否存在或者具有权限 | |
folder="/var/www/" |
NewerOlder