1. 绘制阴影色
在平时开发中,我们经常拿到这样的设计图 , 重点在于经常忽略的阴影色
![](https://img.haomeiwen.com/i2026986/1b6605d408f88465.png)
代码或者sb 中,此控件的masksToBounds = NO
实现代码
CALayer * layer = [self.goContinueBtn layer];
[layer setShadowOffset:CGSizeMake(0, 5)]; //为阴影偏移量,默认为(左右,上下)
[layer setShadowRadius:4];// 为阴影四角圆角半径,默认值为
[layer setShadowOpacity:0.5]; //为阴影透明度(取值为[0,1])
[layer setShadowColor:[[admore_tools getInstance] colorWithHexString:@"248EFF"].CGColor]; //为阴影颜色
2.关于色值问题
- 使用sb 或者xib 中吸色工具
在实际开发中发现,xcode 的吸色是比较方便,但是有时候会色差,吸出的颜色与设计稿不一致 - 使用万能代码设置
开发中,不要担心设计给你的颜色值是 RGB 还是 16进制 的 ,我们都可以使用的,一样方便.
下方即是使用方法
#define COLOR(inColor) RGBA((unsigned char) (inColor >> 16), (unsigned char) (inColor >> 8), (unsigned char) (inColor), 1.0)
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0)
隐藏导航条的 阴影线
[self.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[self.navigationBar setShadowImage:[[UIImage alloc] init]];
获取当前APP的图标信息
NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary];
NSString *icon = [[infoPlist valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"] lastObject];
self.imageView.image = [UIImage imageNamed:icon];
mas 获取导航栏的高度
CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
CGRect rectNav = self.navigationController.navigationBar.frame;
关于设置圆角问题(设置特定位置圆角)
UIRectCorner corner = UIRectCornerTopLeft | UIRectCornerTopRight;
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(12, 12)];
CAShapeLayer * shapeLayer = [CAShapeLayer layer];
shapeLayer.path = path.CGPath;
self.view.layer.mask = shapeLayer;
网友评论