iOS 几个小技巧

1.把tableviewcell的小对勾的颜色改成别的颜色

self.mTableView.tintColor =[UIColor redColor];

2.隐藏导航栏上的返回字体

//Swift

UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0,-60),forBarMetrics: .Default)

//OC

[[UIBarButtonItem appearance]setBackButtonTitlePositionAdjustment:UIOffsetMake(0,-60)forBarMetrics:UIBarMetricsDefault];

3.去掉导航栏下边的黑线

[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc]init]forBarMetrics:UIBarMetricsDefault];

self.navigationController.navigationBar.shadowImage =[[UIImage alloc]init];

修改textFieldplaceholder字体颜色和大小

textField.placeholder = @"username is in here!";[/p][textField setValue:[UIColor redColor]forKeyPath:@"_placeholderLabel.textColor"]; 

[textField setValue:[UIFont boldSystemFontOfSize:16]forKeyPath:@"_placeholderLabel.font"];

4.UIImage与字符串互转

//图片转字符串 

-(NSString*)UIImageToBase64Str:(UIImage *)image 

NSData*data = UIImageJPEGRepresentation(image,1.0f); 

NSString*encodedImageStr =[data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; 

returnencodedImageStr; 

}

//字符串转图片 

-(UIImage *)Base64StrToUIImage:(NSString*)_encodedImageStr 

NSData*_decodedImageData   =[[NSDataalloc]initWithBase64Encoding:_encodedImageStr]; 

UIImage *_decodedImage      =[UIImage imageWithData:_decodedImageData]; 

return_decodedImage; 

}

你可能感兴趣的:(iOS 几个小技巧)