常用的功能总结
来源:互联网 发布:linux卸载oracle11g 编辑:程序博客网 时间:2024/06/02 20:44
http://www.cocoachina.com/ios/20170626/19616.html
[self.tableview respondsToSelector:@selector(setSectionIndexColor:)这个可以叫做动态拦截吧
这个链接是我无意中遇到的,觉得博主很辛苦另外有些代码确实有用,就存了下来
1.去除数组中重复的数据 NSArray *newArr = [oldArr valueForKeyPath:@“@distinctUnionOfObjects.self"];
2.判断图片类型 //通过图片Data数据第一个字节 来获取图片扩展名
- (NSString *)contentTypeForImageData:(NSData *)data
{
uint8_t c;
[data getBytes:&c length:1];
switch (c)
{
case 0xFF:
return @"jpeg";
case 0x89:
return @"png";
case 0x47:
return @"gif";
case 0x49:
case 0x4D:
return @"tiff";
case 0x52:
if ([data length] < 12) {
return nil;
}
NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding];
if ([testString hasPrefix:@"RIFF"]
&& [testString hasSuffix:@"WEBP"])
{
return @"webp";
}
return nil;
}
return nil;
}
3.身份证验证正则表达式
- (BOOL)validateIdentityCard {
BOOL flag;
if (self.length <= 0) {
flag = NO;
return flag;
}
NSString *regex2 = @"^(\\d{14}|\\d{17})(\\d|[xX])$";
NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
return [identityCardPredicate evaluateWithObject:self];
}
4.合并两个图片
+ (UIImage*)mergeImage:(UIImage*)firstImage withImage:(UIImage*)secondImage {
CGImageRef firstImageRef = firstImage.CGImage;
CGFloat firstWidth = CGImageGetWidth(firstImageRef);
CGFloat firstHeight = CGImageGetHeight(firstImageRef);
CGImageRef secondImageRef = secondImage.CGImage;
CGFloat secondWidth = CGImageGetWidth(secondImageRef);
CGFloat secondHeight = CGImageGetHeight(secondImageRef);
CGSize mergedSize = CGSizeMake(MAX(firstWidth, secondWidth), MAX(firstHeight, secondHeight));
UIGraphicsBeginImageContext(mergedSize);
[firstImage drawInRect:CGRectMake(0, 0, firstWidth, firstHeight)];
[secondImage drawInRect:CGRectMake(0, 0, secondWidth, secondHeight)];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return
image;
}
// 画水印
- (void) setImage:(UIImage *)image withWaterMark:(UIImage *)mark inRect:(CGRect)rect
{
if
([[[UIDevice currentDevice] systemVersion] floatValue] >= 4.0)
{
UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
}
//原图
[image drawInRect:self.bounds];
//水印图
[mark drawInRect:rect];
UIImage *newPic = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.image = newPic;
}
- 常用的功能总结
- 总结常用的 JS 功能
- 对于常用分页功能的总结
- grep命令最常用的功能总结
- grep命令最常用的功能总结
- js的常用功能及属性总结
- Unity3d 常用功能总结
- iptables 常用功能总结
- JavaScript 常用功能总结
- JavaScript 常用功能总结
- Jquery常用功能总结
- git常用功能总结
- Charles常用功能总结
- Vim常用功能总结
- Git 常用功能总结
- JavaScript 常用功能总结
- python常用功能总结
- 对gulp构建工具的一些常用功能的总结
- Hibernate基础(2)
- C++ 冒泡排序
- Trafodion Troubleshooting-NotServingRegionException region is not online
- OMACP密码类型
- MyBatis的ResultMaps之一对多关系
- 常用的功能总结
- HIbernate 中 is not maped. 解决方法
- 杨氏矩阵:有一个二维数组,数组的每行从左到右都是递增的,每列从上到下都是递增的,从这样的数组中查找一个数字是否存在
- Hibernate基础(3)
- 前端发送url地址后端处理
- F4V/M3U8/比特率/LocalDNS/HttpDNS/traceroute
- 遇到的linux部分命令
- HoloLens开发笔记-v1.5.7.0自带例程使用
- C语言面试题大汇总