1.設(shè)置UILable? 的行間距? 和 計(jì)算帶行間距的高度
/*
UILabel*?展示的控件
(NSString*)str??內(nèi)容
withFont:(float)font?字體大小
WithSpace:(float)space?行間距
*/
//給UILabel設(shè)置行間距和字間距
-(void)setLabelSpace:(UILabel*)label?withValue:(NSString*)str?withFont:(float)font?WithSpace:(float)space{
NSMutableParagraphStyle?*paraStyle?=?[[NSMutableParagraphStyle?alloc]?init];
paraStyle.lineBreakMode?=?NSLineBreakByCharWrapping;
paraStyle.alignment?=?NSTextAlignmentLeft;
paraStyle.lineSpacing?=?space;//設(shè)置行間距
paraStyle.hyphenationFactor?=?1.0;
paraStyle.firstLineHeadIndent?=?0.0;
paraStyle.paragraphSpacingBefore?=?0.0;
paraStyle.headIndent?=?0;
paraStyle.tailIndent?=?0;
//設(shè)置字間距?NSKernAttributeName:@1.5f
UIFont?*tfont?=?[UIFont?systemFontOfSize:font];
NSDictionary?*dic?=?@{NSFontAttributeName:tfont,?NSParagraphStyleAttributeName:paraStyle,?NSKernAttributeName:@1.5f
};
NSAttributedString?*attributeStr?=?[[NSAttributedString?alloc]?initWithString:str?attributes:dic];
label.attributedText?=?attributeStr;
}
/*
計(jì)算UILabel的高度(帶有行間距的情況)
(NSString*)str??內(nèi)容
withFont:(float)font?字體大小
WithSpace:(float)space?行間距
(CGFloat)width??UILable的寬度
*/
//計(jì)算UILabel的高度(帶有行間距的情況)
-(CGFloat)getSpaceLabelHeight:(NSString*)str?withFont:(float)font?withWidth:(CGFloat)width?WithSpace:(float)space{
NSMutableParagraphStyle?*paraStyle?=?[[NSMutableParagraphStyle?alloc]?init];
paraStyle.lineBreakMode?=?NSLineBreakByCharWrapping;
paraStyle.alignment?=?NSTextAlignmentLeft;
paraStyle.lineSpacing?=?space;
paraStyle.hyphenationFactor?=?1.0;
paraStyle.firstLineHeadIndent?=?0.0;
paraStyle.paragraphSpacingBefore?=?0.0;
paraStyle.headIndent?=?0;
paraStyle.tailIndent?=?0;
UIFont?*tfont?=?[UIFont?systemFontOfSize:font];
NSDictionary?*dic?=?@{NSFontAttributeName:tfont,?NSParagraphStyleAttributeName:paraStyle,?NSKernAttributeName:@1.5f
};
CGSize?size?=?[str?boundingRectWithSize:CGSizeMake(width,?CGFLOAT_MAX)?options:NSStringDrawingUsesLineFragmentOrigin?attributes:dic?context:nil].size;
returnsize.height;
}
2.禁止程序運(yùn)行時(shí)自動(dòng)鎖屏
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
3.取消系統(tǒng)的返回手勢(shì)
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
4.百度坐標(biāo)跟火星坐標(biāo)相互轉(zhuǎn)換
//百度轉(zhuǎn)火星坐標(biāo)
+?(CLLocationCoordinate2D?)bdToGGEncrypt:(CLLocationCoordinate2D)coord
{
double?x?=?coord.longitude?-?0.0065,?y?=?coord.latitude?-?0.006;
double?z?=?sqrt(x?*?x?+?y?*?y)?-?0.00002?*?sin(y?*?M_PI);
double?theta?=?atan2(y,?x)?-?0.000003?*?cos(x?*?M_PI);
CLLocationCoordinate2D?transformLocation?;
transformLocation.longitude?=?z?*?cos(theta);
transformLocation.latitude?=?z?*?sin(theta);
returntransformLocation;
}
//火星坐標(biāo)轉(zhuǎn)百度坐標(biāo)
+?(CLLocationCoordinate2D?)ggToBDEncrypt:(CLLocationCoordinate2D)coord
{
double?x?=?coord.longitude,?y?=?coord.latitude;
double?z?=?sqrt(x?*?x?+?y?*?y)?+?0.00002?*?sin(y?*?M_PI);
double?theta?=?atan2(y,?x)?+?0.000003?*?cos(x?*?M_PI);
CLLocationCoordinate2D?transformLocation?;
transformLocation.longitude?=?z?*?cos(theta)?+?0.0065;
transformLocation.latitude?=?z?*?sin(theta)?+?0.006;
returntransformLocation;
}
6.簡(jiǎn)單寫(xiě)出增敛劝、刪、改尤仍、查的SQL語(yǔ)句
增: ? insert into tb_blogs(name, url) values('aaa','http://www.baidu.com');
刪:deletefrom?tb_blogs?where?blogid?=?1;
改:update?tb_blogs?set?url?='www.baidu.com'where?blogid?=?1;
查: ? select?name,?url?from?tb_blogs?where?blogid?=?1;