首页 > 代码库 > 关于iOS小的知识点
关于iOS小的知识点
由于是随意的知识点,不根据某个方面来写。
1.关于Xcode6模拟器键盘不弹出 -> Command + Shift + K
2.关于调用剪切板复制字符串
+ (void)copyTextWithStr:(NSString *)str { UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; // 复制到剪切板 pasteboard.string = str; }
3.设置16进制颜色
+ (UIColor *)colorWithRGBHex:(UInt32)hex { int r = (hex >> 16) & 0xFF; int g = (hex >> 8) & 0xFF; int b = (hex) & 0xFF; return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f]; }
4.打印LOG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
5.定义Window/APPDelegate
#define APPLICATION ([UIApplication sharedApplication]) #define WINDOW ([[UIApplication sharedApplication].windows lastObject])
#define NAV_H 44 #define TOP_Y (iOS_7 ? 64 : NAV_H) #define TOP_TABLE_VIEW_H ((iOS_7 ? 64 : NAV_H) + NAV_H)
7.UIImage截圆
+(UIImage*)CircleImage:(UIImage*)image withParam:(CGFloat)inset withFrame:(CGRect)frame { CGImageRef imageRef = image.CGImage ; CGImageRef resultImgRef = CGImageCreateWithImageInRect(imageRef, frame) ; UIImage *resultImg = [UIImage imageWithCGImage:resultImgRef scale:image.scale orientation:image.imageOrientation] ; CGImageRelease(resultImgRef) ; UIGraphicsBeginImageContext(resultImg.size); CGContextRef context = UIGraphicsGetCurrentContext(); // CGContextSetLineWidth(context, 1); // CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor); CGRect rect = CGRectMake(inset, inset, resultImg.size.width - inset, resultImg.size.height - inset); CGContextAddEllipseInRect(context, rect); CGContextClip(context); [resultImg drawInRect:rect]; // CGContextAddEllipseInRect(context, rect); // CGContextStrokePath(context); UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newimg; }
8.MD5加密
- (NSString *)MD5 { const char *cStr = [self UTF8String]; unsigned char result[16]; CC_MD5( cStr, (UInt32)strlen(cStr), result ); return [NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15] ]; }
关于iOS小的知识点
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。