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
我问了gitee官方号,后来让我加QQ群,官方解答是,gitee普通版的page不支持自动更新,pro版本才支持。唉,真的辣鸡,要不是github的加速被国内墙了,访问慢。我会用gitee,强烈要求实现自动更新。 |
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
mx:借鉴了SVProgressHUD的方式 | |
NSBundle *bundle = [NSBundle bundleForClass:[SVProgressHUD class]]; | |
NSURL *url = [bundle URLForResource:@"SVProgressHUD" withExtension:@"bundle"]; | |
NSBundle *imageBundle = [NSBundle bundleWithURL:url]; | |
NSString *path = [imageBundle pathForResource:@"angle-mask" ofType:@"png"]; | |
maskLayer.contents = (__bridge id)[[UIImage imageWithContentsOfFile:path] CGImage]; | |
maskLayer.frame = _indefiniteAnimatedLayer.bounds; |
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
DEMO:https://github.com/awliu/demo_dispatch_group | |
dispatch_group 基本语法 | |
dispatch_group_t group = dispatch_group_create(); | |
dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
// 执行第一个1个耗时的异步操作 | |
}); | |
dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ |
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
主线程定时执行 | |
@property (nonatomic, strong) dispatch_source_t timer; | |
// 【主线程】:2秒后隔2秒执行1次共执行多次 | |
- (void)setupMainThreadJJGCDTimerWithStartTimeSinceNow:(float)satrttime interval:(float)intervaltime repeatcount:(int)repeatcount | |
{ | |
dispatch_queue_t queue = dispatch_get_main_queue(); | |
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); | |
dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(satrttime * NSEC_PER_SEC)); |
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
主线程延迟 | |
// 【主线程】:延迟2秒后执行1次 | |
- (void)setupMainThreadDelayInSecond:(float)second{ | |
double delayInSeconds = second; | |
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); | |
dispatch_after(time, dispatch_get_main_queue(), ^(void){ | |
// 执行事件 | |
NSLog(@"setupMainThreadDelayInSecond------------%@", [NSThread currentThread]); | |
}); |
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
方法1:使用dispatch_get_main_queue | |
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
// 执行耗时的异步操作...CODE | |
NSLog(@" 处理子线程工作"); | |
[NSThread sleepForTimeInterval:2]; | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
// 回到主线程,执行UI刷新操作 | |
NSLog(@" 处理主线程工作"); |
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
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// 只执行1次的代码(这里面默认是线程安全的) | |
}); |
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
单例(初始化情况少) | |
//id 可以是任何类名 | |
+ (instancetype)sharedInstance{ | |
static id _instance; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
_instance = [[self alloc] init]; | |
}); | |
return _instance; |
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
typedef void(^handler)(void); | |
typedef void(^completion)(BOOL finished); | |
@property handler handler; | |
@property completion completion; |
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
效果图链接:https://raw.githubusercontent.com/codeRiding/github_pic_0001/master/2020-03-26 21.01.10.gif | |
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { | |
UIView* bgSelectionView = [UIView new]; | |
bgSelectionView.backgroundColor = [UIColor redColor]; | |
cell.selectedBackgroundView = bgSelectionView; | |
} | |
https://gist.github.com/0c984c8a7b66933d75ee2fe5041c4ce6 |
NewerOlder