你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
裸奔
赞同来自:
涵秋
UIView * separator = [[UIView alloc] initWithFrame:CGRectMake/x, y, 320, 1/]; separator.backgroundColor = [UIColor colorWithWhite:0.7 alpha:1]; [self.view addSubview:separator]; [separator release];
八刀丁二
import UIKit class HairlineView: UIView { override func awakeFromNib// { guard let backgroundColor = self.backgroundColor?.CGColor else { return } self.layer.borderColor = backgroundColor self.layer.borderWidth = /1.0 / UIScreen.mainScreen//.scale/ / 2; self.backgroundColor = UIColor.clearColor// } }
石油百科
UIView *horizontalLine = [[UIView alloc]initWithFrame:CGRectMake/x cordinate,y cordinate,1,linelenth/]; horizontalLine.backgroundColor = [UIColor blackColor]; [self. view addSubView:horizontalLine]; [horizontalLine release];
UIView *verticalLine = [[UIView alloc]initWithFrame:CGRectMake/x cordinate,y cordinate,linelenth,1/]; verticalLine.backgroundColor = [UIColor blackColor]; [self. view addSubView:verticalLine]; [verticalLine release];
君笑尘
extension CALayer { func addBorder/edge: UIRectEdge, color: UIColor, thickness: CGFloat/ { let border = CALayer// switch edge { case .top: border.frame = CGRect/x: 0, y: 0, width: frame.width, height: thickness/ case .bottom: border.frame = CGRect/x: 0, y: frame.height - thickness, width: frame.width, height: thickness/ case .left: border.frame = CGRect/x: 0, y: 0, width: thickness, height: frame.height/ case .right: border.frame = CGRect/x: frame.width - thickness, y: 0, width: thickness, height: frame.height/ default: break } border.backgroundColor = color.cgColor; addSublayer/border/ }
奔跑吧少年
- /void/drawRect:/CGRect/rect { //// General Declarations CGContextRef context = UIGraphicsGetCurrentContext//; //// Shadow Declarations CGColorRef outerShadow = [UIColor blackColor].CGColor; CGSize outerShadowOffset = CGSizeMake/0, 1/; CGFloat outerShadowBlurRadius = 2; //// Abstracted Graphic Attributes CGRect rectangleFrame = CGRectMake/0, 0, self.frame.size.width, 3/; //// Rectangle Drawing UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRect: rectangleFrame]; [[UIColor lightGrayColor] setFill]; [rectanglePath fill]; ////// Rectangle Inner Shadow CGRect rectangleBorderRect = CGRectInset/[rectanglePath bounds], -outerShadowBlurRadius, -outerShadowBlurRadius/; rectangleBorderRect = CGRectOffset/rectangleBorderRect, -outerShadowOffset.width, -outerShadowOffset.height/; rectangleBorderRect = CGRectInset/CGRectUnion/rectangleBorderRect, [rectanglePath bounds]/, -1, -1/; UIBezierPath* rectangleNegativePath = [UIBezierPath bezierPathWithRect: rectangleBorderRect]; [rectangleNegativePath appendPath: rectanglePath]; rectangleNegativePath.usesEvenOddFillRule = YES; CGContextSaveGState/context/; { CGFloat xOffset = outerShadowOffset.width + round/rectangleBorderRect.size.width/; CGFloat yOffset = outerShadowOffset.height; CGContextSetShadowWithColor/context, CGSizeMake/xOffset + copysign/0.1, xOffset/, yOffset + copysign/0.1, yOffset//, outerShadowBlurRadius, outerShadow/; [rectanglePath addClip]; CGAffineTransform transform = CGAffineTransformMakeTranslation/-round/rectangleBorderRect.size.width/, 0/; [rectangleNegativePath applyTransform: transform]; [[UIColor grayColor] setFill]; [rectangleNegativePath fill]; } CGContextRestoreGState/context/; }
董宝中
let line = UIView// view.addSubview/line/ line.translatesAutoresizingMaskIntoConstraints = false line.widthAnchor.constraint/equalToConstant: view.bounds.width - 40/.isActive = true line.heightAnchor.constraint/equalToConstant: 1/.isActive = true line.leftAnchor.constraint/equalTo: view.leftAnchor, constant: 20/.isActive = true line.topAnchor.constraint/equalTo: userName.bottomAnchor,constant: 20/.isActive = true line.backgroundColor = .gray
要回复问题请先登录或注册
7 个回复
裸奔
赞同来自:
涵秋
赞同来自:
八刀丁二
赞同来自:
实际的头发生长线 1 像素
, 和线宽宽度 2 设备上的像素 2X.
我发现了一条消息
http://www.iriphon.com/2014/02 ... -ios/
如何创建一个厚实的薄发线 1 像素。
我们需要一个子类实用程序 UIView. 为了 Swift 这将是:
石油百科
赞同来自:
对于垂直线
君笑尘
赞同来自:
奔跑吧少年
赞同来自:
董宝中
赞同来自:
线宽等于设备的宽度 - 一些常量,左侧添加相同的常量,所以我们得到一个关于所以的一线