//保存当前view到相册 UIGraphicsBeginImageContext(currentView.bounds.size); //currentView 当前的view [currentView.layer renderInContext:UIGraphicsGetCurrentContext()];
- (NSString *) stringByAppendingRandomStringOfRandomLength; - (int) occurrencesOfString: (NSString *) aString; - (NSDate *) date; + (NSString *) commasForNumber: (long long) num;
string 转成 char: char mychar[100]; NSString * mystring; strcpy(mychar,(char *)[mystring UTF8String]);
#define NUMBERS @"0123456789\n" - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
//每个线段的两点都在另一个线段的左右不同侧,则能断定线段相交 //公式对于向量(x1,y1)->(x2,y2),判断点(x3,y3)在向量的左边,右边,还是线上. //p=x1(y3-y2)+x2(y1-y3)+x3(y2-y1).p<0 左侧, p=0 线上, p>0 右侧
//计算点到线段的最短距离 double x1, y1, x2, y2, x3, y3; double px = x2 - x1; double py = y2 - y1; double som = px * px + py * py; double u = ((x3 - x1) * px + (y3 - y1) * py) / som;
// 是否高清屏 #define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)