做记录
方便管理
强调部分
[self returnColorString:@"hello, i am xiao qu" WithRange:@"7 7,9 10,17 18"];//, 9 10 | |
self.dialogLab.attributedText = [self returnColorString:resultDic.refText WithRange:resultDic.scoreInfo]; | |
- (NSMutableAttributedString *)returnColorString:(NSString *)oldString WithRange:(NSString *)range{ | |
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:oldString]; | |
NSArray *arr = [range componentsSeparatedByString:@","]; | |
for (NSString *rang in arr) { |
NSDate *nowDate = [NSDate date]; | |
NSUserDefaults *dataUser = [NSUserDefaults standardUserDefaults]; | |
[dataUser setObject:nowDate forKey:@"nowDate"]; | |
[dataUser synchronize]; | |
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; | |
NSDate *now = [NSDate date]; | |
NSDate *agoDate = [userDefault objectForKey:@"nowDate"]; | |
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; |
- (void)QRCodeScanVC:(UIViewController *)scanVC { | |
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; | |
if (device) { | |
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; | |
switch (status) { | |
case AVAuthorizationStatusNotDetermined: { | |
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { | |
if (granted) { | |
dispatch_sync(dispatch_get_main_queue(), ^{ | |
[self.navigationController pushViewController:scanVC animated:YES]; |
//https://www.cnblogs.com/syios/p/7692566.html | |
//https://www.jianshu.com/p/35219655d187 | |
-(BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(UIApplicationExtensionPointIdentifier)extensionPointIdentifier{ | |
// 整个app应用内禁用第三方键盘 | |
// if ([extensionPointIdentifier isEqualToString:@"com.apple.keyboard-service"]) { | |
// return NO; | |
// } |
NSArray *familyNames = [UIFont familyNames]; | |
for(NSString *familyName in familyNames ){ | |
printf("Family: %s \n", [familyName UTF8String]); | |
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName]; | |
for(NSString *fontName in fontNames) { |
// 过期的方法 | |
CGSize titleSize = [self.evaluationModel.subjectInfoModel.stems sizeWithFont:KFont_Bold(18) constrainedToSize:CGSizeMake(kMainScreenWidth - LRMragin * 2, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap]; | |
//现在的方法 | |
CGRect rect = [self.lbl_en.text boundingRectWithSize:CGSizeMake(kMainScreenWidth - LRMragin * 2, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: self.lbl_en.font} context:nil]; | |
// YYLable获取文本高度 | |
-(CGFloat)getMessageHeight:(NSString *)mess andLabel:(YYLabel *)lb{ | |
//第一个参数 observer:观察者 (这里观察self.myKVO对象的属性变化) | |
//第二个参数 keyPath: 被观察的属性名称(这里观察 self.myKVO 中 num 属性值的改变) | |
//第三个参数 options: 观察属性的新值、旧值等的一些配置(枚举值,可以根据需要设置,例如这里可以使用两项) | |
//第四个参数 context: 上下文,可以为 KVO 的回调方法传值(例如设定为一个放置数据的字典) | |
[self.myKVO addObserver:self | |
forKeyPath:@"num" | |
options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew | |
context:nil]; | |
//GIF 的播放次数是 GIF 图片本身的属性,这应该是只读的。想要控制循环次数,大概有几种方法: | |
//1.如果你不能控制 GIF 图片内容,那你可以监听 YYAnimatedImageView 的 currentAnimatedImageIndex 属性,当播放到最后一帧时,调用 stopAnimating 停止动画。 | |
//2.子类化 YYImage,把循环次数这个属性暴露出来:ibireme/YYImage#1 | |
//3.用比较 hack 的方法来做: | |
if ([image isKindOfClass:[YYImage class]]) { | |
YYImageDecoder *decoder = [image valueForKey:@"_decoder"]; |
- (void)line{ | |
UIImageView *iView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 200, 20)]; | |
[self.view addSubview:iView]; | |
UIGraphicsBeginImageContext(iView.frame.size); //参数size为新创建的位图上下文的大小 | |
[iView.image drawInRect:CGRectMake(0, 0, iView.frame.size.width, iView.frame.size.height)]; | |
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapSquare); //设置线段收尾样式 | |
CGFloat length[] = {2,1}; // 线的宽度,间隔宽度 |