2. 散装
[self bringSubviewToFront:view]; //将某个子视图调整到所有子视图前方显示
[self sendSubviewToBack:_backView]; //将某个视图发送到所有视图之后显示
[self insertSubview:view atIndex:2]; //将视图插到某个视图的处
[self insertSubview:view aboveSubview:viewlast]; //将第一个视图插到最后一个视图的上方
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"topborbg"] forBarMetrics:UIBarMetricsDefault]; //导航栏背景图片
[view.layer setCornerRadius:5]; //圆角半径
[view.layer setBorderWidth:1]; //边宽
[view.layer setBorderColor:[UIColor greenColor].CGColor]; //边框颜色
self.pageContenter.layer.shadowColor= [UIColorblackColor].CGColor;//阴影颜色
self.pageContenter.layer.shadowOffset=CGSizeMake(0,0);//阴影偏移
self.pageContenter.layer.shadowOpacity=0.5;//阴影不透明度
self.pageContenter.layer.shadowRadius=5.0;//阴影半径
[UIFont boldSystemFontOfSize:13.0]; //粗体
[btn_information setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; //buttom 永远不变字体颜色
btn_information.titleLabel.textColor = [UIColor whiteColor]; //buttom 只能用一次
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window //仅仅支持横屏幕
{
return UIInterfaceOrientationMaskPortrait;
}
[UIView animateWithDuration:0.3 animations:^{
_superScrollView.contentOffset = CGPointMake(0, view.frame.origin.y); //block动画
}];
Mac:~/资源库/Application Support/MobileSync/备份/
UITableViewCell * cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]; //从tableview里取出cell
UITableViewCell * cell = [_tableView cellForRowAtIndexPath:indexPath];
[_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; //tableview没有分割线
self.selectionStyle = UITableViewCellSelectionStyleNone; //cell 选择无色
NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"退改签"]]; //下划线
NSRange contentRange = {0,[content length]};
content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
label.attributedText = content;
find . -name "*.m" -or -name "*.h" |xargs grep -v "^$"|wc -l //计算项目行数
[ UIScreen mainScreen ].applicationFrame.size.height 548 //不包含状态栏
[[UIScreen mainScreen] bounds].size.height 568 //包含状态栏
- (BOOL)prefersStatusBarHidden //iOS7隐藏状态栏和导航栏
{
return YES;
}
-(void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden = YES;
}
- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode NS_DEPRECATED_IOS(2_0, 7_0, "Use -boundingRectWithSize:options:attributes:context:"); // NSTextAlignment is not needed to determine size //计算文本高度
UILabel *l = [[UILabel alloc] initWithFrame:_csView.bounds]; //Label直接显示在view的中间
dispatch_async(dispatch_get_global_queue(0, 0), ^{}); //开多线程
dispatch_async(dispatch_get_main_queue(), ^{}); //回主线程
NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://imhomepage/w7ba722s8ky7uyzc.png"]]; //下载图片
UIImage * result = [UIImage imageWithData:data];
showCustomAlertMessage(@"请在系统设置中打开\"定位服务\"来允许\"12580\"确定您的位置"); //在字符串中添加双引号
[UIImageJPEGRepresentation([UIImage imageWithData:imageData], 1.0) length] //计算图片大小
- (UIImage*) imageWithUIView:(UIView*) view //view 转成 image
{
UIGraphicsBeginImageCont
CGContextRef context = UIGraphicsGetCurrentCont
[view.layer renderInContext:context];
UIImage* tImage =UIGraphicsGetImageFromCu
UIGraphicsEndImageContex
return tImage;
}
//让界面上的所有可能是第一响应者的对象放弃第一响应
-(void)resignAllFirstResponder:(UIView*)supperView{
for (UIView *view in supperView.subviews){
if ([view isKindOfClass:[UITextView class]])
[view resignFirstResponder];
else{
if ([[view subviews] count]!=0)
[self resignAllFirstResponder:view];
}}}
tabelView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0); //tableView的cell分割线位置靠左
启动页面去除状态栏 在info.plist添加行Status bar is initially hidden = YES
//底层画线
CAShapeLayer *lineShape = nil;
CGMutablePathRef linePath = nil;
linePath = CGPathCreateMutable();
lineShape = [CAShapeLayer layer];
lineShape.lineWidth = 0.5;
lineShape.lineCap = kCALineCapRound;
[lineShape setStrokeColor:[UIColor colorWithRed:(float)169/255 green:(float)169/255 blue:(float)169/255 alpha:1].CGColor];
int x = 0; int y = 79;
int toX = 320; int toY = 80;
CGPathMoveToPoint(linePath, NULL, x, y);
CGPathAddLineToPoint(linePath, NULL, toX, toY);
lineShape.path = linePath;
CGPathRelease(linePath);
[self.layer addSublayer:lineShape];
webView.backgroundColor = [UIColor whiteColor]; //webview背景色
webView.opaque = NO;
需要ARC的文件双击,并在输入框中输入:-fobjc-arc,如果不要ARC则输入:-fno-objc-arc
1. 获取农历
- (void)viewDidLoad
{[super viewDidLoad];
NSString* string = @"20131226";
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"yyyyMMdd"];
NSDate* inputDate = [inputFormatter dateFromString:string];
NSLog(@"date = %@",[self getChineseCalendarWithDate:inputDate]);
}
-(NSString*)getChineseCalendarWithDate:(NSDate *)date
{
NSArray *chineseYears = [NSArray arrayWithObjects:
@"甲子", @"乙丑", @"丙寅", @"丁卯", @"戊辰", @"己巳", @"庚午", @"辛未", @"壬申", @"癸酉",
@"甲戌", @"乙亥", @"丙子", @"丁丑", @"戊寅", @"己卯", @"庚辰", @"辛己", @"壬午", @"癸未",
@"甲申", @"乙酉", @"丙戌", @"丁亥", @"戊子", @"己丑", @"庚寅", @"辛卯", @"壬辰", @"癸巳",
@"甲午", @"乙未", @"丙申", @"丁酉", @"戊戌", @"己亥", @"庚子", @"辛丑", @"壬寅", @"癸丑",
@"甲辰", @"乙巳", @"丙午", @"丁未", @"戊申", @"己酉", @"庚戌", @"辛亥", @"壬子", @"癸丑",
@"甲寅", @"乙卯", @"丙辰", @"丁巳", @"戊午", @"己未", @"庚申", @"辛酉", @"壬戌", @"癸亥", nil];
NSArray *chineseMonths=[NSArray arrayWithObjects:
@"正月", @"二月", @"三月", @"四月", @"五月", @"六月", @"七月", @"八月",
@"九月", @"十月", @"冬月", @"腊月", nil];
NSArray *chineseDays=[NSArray arrayWithObjects:
@"初一", @"初二", @"初三", @"初四", @"初五", @"初六", @"初七", @"初八", @"初九", @"初十",
@"十一", @"十二", @"十三", @"十四", @"十五", @"十六", @"十七", @"十八", @"十九", @"二十",
@"廿一", @"廿二", @"廿三", @"廿四", @"廿五", @"廿六", @"廿七", @"廿八", @"廿九", @"三十", nil];
NSCalendar *localeCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSChineseCalendar];
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents *localeComp = [localeCalendar components:unitFlags fromDate:date];
NSLog(@"%d_%d_%d %@",localeComp.year,localeComp.month,localeComp.day, localeComp.date);
NSString *y_str = [chineseYears objectAtIndex:localeComp.year-1];
NSString *m_str = [chineseMonths objectAtIndex:localeComp.month-1];
NSString *d_str = [chineseDays objectAtIndex:localeComp.day-1];
NSString *chineseCal_str =[NSString stringWithFormat: @"%@_%@_%@",y_str,m_str,d_str];
return chineseCal_str;
}