MessageKitのライブラリを使ってまして、
backgroundColorであれば色を背景色変えることができるのですが、
レイヤーを使ってグラデーションさせると画像のように何も変わりません。
なので、backgroundColor自体でグラデーションさせたいのですが何か方法はありませんでしょうか?
swift
1 //グラデーションの開始色 2 let topColor = UIColor.red 3 //グラデーションの開始色 4 let bottomColor = UIColor.blue 5 6 //グラデーションの色を配列で管理 7 let gradientColors: [CGColor] = [topColor.cgColor, bottomColor.cgColor] 8 9 //グラデーションレイヤーを作成 10 let gradientLayer: CAGradientLayer = CAGradientLayer() 11 12 //グラデーションの色をレイヤーに割り当てる 13 gradientLayer.colors = gradientColors 14 //グラデーションレイヤーをスクリーンサイズにする 15 gradientLayer.frame = messagesCollectionView.frame 16 gradientLayer.locations = [0.0, 1.0] 17 // 上から下へグラデーション向きの設定 18 gradientLayer.startPoint = CGPoint.init(x: 0, y: 0) 19 gradientLayer.endPoint = CGPoint.init(x: 1, y: 1) 20 //グラデーションレイヤーをビューの一番下に配置 21 messagesCollectionView.layer.insertSublayer(gradientLayer, at:0) 22 23// messagesCollectionView.backgroundColor = UIColor.red 24 messageInputBar.backgroundColor = UIColor.clear 25 messageInputBar.backgroundView.backgroundColor = UIColor.clear
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。