0
私のセグメント化されたコントロールのすぐ下にコレクションビューを配置したいと思いますが、制約が間違っているかどうかはわかりません。また、フレーム幅全体から10を引いたものの、collectionViewの上に中心を置くために、私の分割されたコントロールを配置したいと思います。UICollectionView位置とセグメント化されたコントロールがプログラム的にエラー
相続人は、私がしようとしているコード:
let item = ["Past", "Future"]
let customSC = UISegmentedControl(items: item)
customSC.selectedSegmentIndex = 0
let frame = UIScreen.mainScreen().bounds
customSC.frame = CGRectMake(0, 0,
frame.width, 25)
customSC.layer.cornerRadius = 5.0 // Don't let background bleed
customSC.backgroundColor = MaterialColor.white
customSC.tintColor = MaterialColor.red.accent3
customSC.translatesAutoresizingMaskIntoConstraints = false
//customSC.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor)
//collectionView?.translatesAutoresizingMaskIntoConstraints = false
collectionView?.addSubview(customSC)
customSC.centerXAnchor.constraintEqualToAnchor(collectionView?.centerXAnchor).active = true
//collectionView?.topAnchor.constraintEqualToAnchor(customSC.bottomAnchor,constant: 2).active = true
をここでは私の出力の画像です。セグメント化されたコントロールのすぐ下に表示するように、全体の幅のフレームとコレクションのビューを塗りつぶす最初のビューになりました。
感謝。