2017-12-13 8 views
0

単純なUIView行を作成してからその上に円を作成しようとしています。しかし、私はどのように階層の問題を作らずにサークルを描くと思いますか?これまでのところ、私はライン円が重複しているビューを作成する

ライン

self.stepLine = UIView() 
    self.stepLine.translatesAutoresizingMaskIntoConstraints = false 
    stepView.addSubview(self.stepLine) 

    self.stepLine.backgroundColor = Color.theme.value 

    self.stepLine.bottomAnchor.constraint(equalTo: stepView.bottomAnchor, constant: -4).isActive = true 
    self.stepLine.heightAnchor.constraint(equalToConstant: 6).isActive = true 
    self.stepLine.leftAnchor.constraint(equalTo: stepView.leftAnchor).isActive = true 



override func layoutSubviews() { 
    self.stepLine.widthAnchor.constraint(equalToConstant: self.frame.width/2).isActive = true 
} 

イラスト

enter image description here

+0

"私はシンプルなUIViewラインを作成しようとしています。どこに描く? –

+0

「階層の問題」とは何を意味しますか? – Paulw11

答えて

0
let circleView = UIView() 
circleView.layer.cornerRadius = 10 // half of the width/height dimension 
circleView.translatesAutoresizingMaskIntoConstraints = false 
stepView.addSubview(circleView) 

circleView.centerYAnchor.constraint(equalTo: stepLine.centerYAnchor).isActive = true 
circleView.trailingAnchor.constraint(equalTo: stepLine.trailingAnchor).isActive = true 
circleView.widthAnchor.constraint(equalToConstant: 20).isActive = true 
circleView.heightAnchor.constraint(equalToConstant: 20).isActive = true 

またはそれらのいくつかのバリエーションを作成突出しており、以下があります。しかし、これはあなたが提示したコードの性質を考えれば、私が示唆する一般的な概念です。

関連する問題