This file contains hidden or 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
/// 方法一:MPMoviePlayerController | |
NSString *videoURL = @"http:// or /private(local video)" | |
NSURL *URL = [NSURL URLWithString: videoURL]; | |
// NSURL *URL = [NSURL fileURLWithPath:videoURL] | |
MPMoviePlayerController *iosMPMovie = [[MPMoviePlayerController alloc]initWithContentURL:URL]; iosMPMovie.shouldAutoplay = NO; | |
UIImage *thumbnail = [iosMPMovie thumbnailImageAtTime:time timeOption:MPMovieTimeOptionNearestKeyFrame]; | |
/// 方法二:AVAssetImageGenerator | |
+ (UIImage *)getThumbnailImage:(NSString *)videoURL { |
This file contains hidden or 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
#import "UIAlertController+JHTapDismiss.h" | |
@interface UIAlertController ()<UIGestureRecognizerDelegate> | |
@end | |
@implementation UIAlertController (JHTapDismiss) | |
- (void)alertTapDismiss { | |
This file contains hidden or 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
“Content Hugging Priority”,也叫内容紧靠优先级(小名:别扯我),该优先级越高,这越晚轮到被拉伸。 | |
“Content Compression Resistance Priority”,也叫内容压缩阻力优先级(小名:别挤我),该优先级越高,则越晚轮到被压缩。 | |
// ⤴️原文: https://www.jianshu.com/p/a4b8e0c8e68d | |
// 紧靠能力 优先级越低 内容显示得越完整 反之,内容被省略 | |
[self.nameLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal]; | |
[self.priceLabel setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal]; |
This file contains hidden or 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
/// 待分组数据 以年为单位分组 | |
NSMutableArray *data = [NSMutableArray array]; | |
for (int i = 2018; i > 2010; i--) { | |
NSString *typeValue = [NSString stringWithFormat:@"%d年",i]; | |
for (int j = 1; j < 5; j++) { | |
NSString *other = [NSString stringWithFormat:@"月份: %d月",j+(arc4random() % 5)]; | |
[data addObject:@{@"year":typeValue,@"month":other}]; | |
} | |
} |
This file contains hidden or 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)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { | |
CGFloat y = scrollView.contentOffset.y; | |
if (y < -65) { | |
[self.collectionView.mj_header beginRefreshing]; | |
// 消除刷新时functionView跳动的问题 动画时间不低于0.25s | |
UIEdgeInsets inset = scrollView.contentInset; | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[UIView animateWithDuration:0.25 animations:^{ |
This file contains hidden or 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
#### OC版 | |
/// #import <CommonCrypto/CommonDigest.h> | |
/// (Category) | |
- (NSString *)md5 { | |
const char *str = [self UTF8String]; | |
if (str == NULL) { | |
str = ""; | |
} | |
unsigned char r[CC_MD5_DIGEST_LENGTH]; |