1. 设置button文字左面 图片右面
- (void) setEdgeSet:(UIButton *)btn{
CGFloat labelWidth = [btn.titleLabel.text sizeWithAttributes:@{NSFontAttributeName:btn.titleLabel.font}].width;
;
[btn setTitleEdgeInsets:UIEdgeInsetsMake(0, -12, 0, 12)];
[btn setImageEdgeInsets:UIEdgeInsetsMake(0, labelWidth +3 , 0, -labelWidth -3)];
}
btn.imageEdgeInsets = UIEdgeInsetsMake(0, btn.frame.size.width - btn.imageView.frame.origin.x - btn.imageView.frame.size.width, 0, 0);
btn.titleEdgeInsets = UIEdgeInsetsMake(0, -(btn.frame.size.width - btn.imageView.frame.size.width ), 0, 0);
2.git 忽略文件
git config --global core.excludesfile ~/.gitignore
echo .DS_Store >> ~/.gitignore
3.设置UITabbar 选中颜色
self.tabBar.unselectedItemTintColor = HEXCOLOR(0x393f53);
self.tabBar.selectedImageTintColor = HEXCOLOR(0x009bbd);
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:HEXCOLOR(0x393f53)} forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:HEXCOLOR(0x009bbd)} forState:UIControlStateSelected];
4. 同时设置阴影和圆角
/*
周边加阴影,并且同时圆角
*/
- (void)addShadowToView:(UIView *)view
withOpacity:(float)shadowOpacity
shadowRadius:(CGFloat)shadowRadius
andCornerRadius:(CGFloat)cornerRadius
{
shadow /
CALayer *shadowLayer = [CALayer layer];
shadowLayer.frame = view.layer.frame;
shadowLayer.shadowColor = [UIColor blackColor].CGColor;//shadowColor阴影颜色
shadowLayer.shadowOffset = CGSizeMake(0, 0);//shadowOffset阴影偏移,默认(0, -3),这个跟shadowRadius配合使用
shadowLayer.shadowOpacity = shadowOpacity;//0.8;//阴影透明度,默认0
shadowLayer.shadowRadius = shadowRadius;//8;//阴影半径,默认3
//路径阴影
UIBezierPath *path = [UIBezierPath bezierPath];
float width = shadowLayer.bounds.size.width;
float height = shadowLayer.bounds.size.height;
float x = shadowLayer.bounds.origin.x;
float y = shadowLayer.bounds.origin.y;
CGPoint topLeft = shadowLayer.bounds.origin;
CGPoint topRight = CGPointMake(x + width, y);
CGPoint bottomRight = CGPointMake(x + width, y + height);
CGPoint bottomLeft = CGPointMake(x, y + height);
CGFloat offset = -1.f;
[path moveToPoint:CGPointMake(topLeft.x - offset, topLeft.y + cornerRadius)];
[path addArcWithCenter:CGPointMake(topLeft.x + cornerRadius, topLeft.y + cornerRadius) radius:(cornerRadius + offset) startAngle:M_PI endAngle:M_PI_2 * 3 clockwise:YES];
[path addLineToPoint:CGPointMake(topRight.x - cornerRadius, topRight.y - offset)];
[path addArcWithCenter:CGPointMake(topRight.x - cornerRadius, topRight.y + cornerRadius) radius:(cornerRadius + offset) startAngle:M_PI_2 * 3 endAngle:M_PI * 2 clockwise:YES];
[path addLineToPoint:CGPointMake(bottomRight.x + offset, bottomRight.y - cornerRadius)];
[path addArcWithCenter:CGPointMake(bottomRight.x - cornerRadius, bottomRight.y - cornerRadius) radius:(cornerRadius + offset) startAngle:0 endAngle:M_PI_2 clockwise:YES];
[path addLineToPoint:CGPointMake(bottomLeft.x + cornerRadius, bottomLeft.y + offset)];
[path addArcWithCenter:CGPointMake(bottomLeft.x + cornerRadius, bottomLeft.y - cornerRadius) radius:(cornerRadius + offset) startAngle:M_PI_2 endAngle:M_PI clockwise:YES];
[path addLineToPoint:CGPointMake(topLeft.x - offset, topLeft.y + cornerRadius)];
//设置阴影路径
shadowLayer.shadowPath = path.CGPath;
cornerRadius /
view.layer.cornerRadius = cornerRadius;
view.layer.masksToBounds = YES;
view.layer.shouldRasterize = YES;
view.layer.rasterizationScale = [UIScreen mainScreen].scale;
[view.superview.layer insertSublayer:shadowLayer below:view.layer];
}
5. 设置导航title,去导航下方阴影
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : K333Color, NSFontAttributeName : UIFont(18)}];
[self.navigationController.navigationBar setShadowImage: [self createImageWithColor:HEXCOLOR(0xe4e4e4)]];
- (UIImage *)createImageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 0.5f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
6. 移除所有subviews
[self.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
7. 返回指定特定viewcontroller
for (UIViewController *temp in self.navigationController.viewControllers) {
if ([temp isKindOfClass:[UpdateUserViewController class]]) {
[self.navigationController popToViewController:temp animated:YES];
}
}