在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
func setHLine(pos:CGFloat) { let rLinePos:CGFloat = pos * UIScreen.main.bounds.height let line: UIView = UIView(frame: CGRect(x: 0, y: Int(rLinePos), width: Int(UIScreen.main.bounds.width), height: 1)) line.backgroundColor = UIColor.gray self.view.addSubview(line) } //使用百分比画竖线 func setVLine(pos:CGFloat) { let rLinePos:CGFloat = pos * UIScreen.main.bounds.width let line: UIView = UIView(frame: CGRect(x: Int(rLinePos), y: 0, width: 1, height: Int(UIScreen.main.bounds.height))) line.backgroundColor = UIColor.gray self.view.addSubview(line) } //使用像素画横线 func setHLineByPixel(pos:Int){ let line: UIView = UIView(frame: CGRect(x: 0, y: pos, width: Int(UIScreen.main.bounds.width), height: 1)) line.backgroundColor = UIColor.gray self.view.addSubview(line) } //使用像素画竖线 func setVLineByPixel(pos:Int){ let line: UIView = UIView(frame: CGRect(x: pos, y: 0, width: 1, height: Int(UIScreen.main.bounds.height))) line.backgroundColor = UIColor.gray self.view.addSubview(line) } 使用方法: override func viewDidLoad() { |
请发表评论