0

UICollectionViewを作成するためにいくつかのココアポッドフレームを使用しています。各セルと設定ビューの適切なデータを取得できます。

違うアニが欲しい

アニメーションの終了点は、dataSource の値に関連付ける必要があります。問題は、didSet 値を思いどおりに使用できないことです。追加したサブビューのフレームは (0,0,0,0) で、オブジェクトの値は didSet の外の初期値と同じです。setupView 関数で dataSource 値にアクセスできません。

期待される効果は、赤いバーが左側から右側に移動することです。

class CereCell : DatasourceCell {

    override var datasourceItem: Any?{
        didSet {
            guard let cere = datasourceItem as? CeremonyDay else { return }
            nameLabel.text = cere.name
            nameLabel.frame = CGRect(x: 0, y: 0, width: 10, height: 10)
currentBar.frame = CGRect(x: 100, y: 100, width: cere.percentage*100 , height: 10)

            position.x = cere.percentage

        }
    }

    let currentBar: UIView =  {
        let currentBar = UIView(frame: CGRect(x: 290, y: 100, width: 300, height: 10))
        currentBar.backgroundColor = .red
        return currentBar
    }()


    override func setupViews() {
        super.setupViews()
        contentView.addSubview(currentBar)
        let frame = currentBar.frame
print(frame)

didSet の値ではない (290, 100, 300, 10) を出力するだけです。

4

0 に答える 0