カードビューを使用してテーブルセルを構築していて、動作していますが、外観を変更したいと思っています。CardViewにスペースを追加するTableViewCell
それは次のようになります。
そして、私はそれが表のセルと、各テーブルセル間のエッジと空間の間のスペースで次のようになりたい:
カードビューテーブルのセルを作成するためのコードは次のとおりです。
class ModelCell: UITableViewCell {
// Outlets
@IBOutlet weak var modelTitleLabel: UILabel!
@IBOutlet weak var modelDescriptionLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
@IBInspectable var cornerRadius: CGFloat = 10
@IBInspectable var shadowOffsetWidth: Int = 0
@IBInspectable var shadowOffsetHeight: Int = 3
@IBInspectable var shadowColor: UIColor? = UIColor.white
@IBInspectable var shadowOpacity: Float = 0.5
override func layoutSubviews() {
layer.cornerRadius = cornerRadius
let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius)
layer.masksToBounds = false
layer.shadowColor = shadowColor?.cgColor
layer.shadowOffset = CGSize(width: shadowOffsetWidth, height: shadowOffsetHeight);
layer.shadowOpacity = shadowOpacity
layer.shadowPath = shadowPath.cgPath
layer.borderWidth = 1.0
layer.borderColor = UIColor(red:0.00, green:0.87, blue:0.39, alpha:1.0).cgColor
}
}
ご協力いただきありがとうございます。
垂直コレクションビューにする必要があります。コレクションビューで簡単に管理できます。 –
@TusharSharma私はこのことをやっていました:https://stackoverflow.com/questions/28141021/do-card-view-with-swiftこれは私が欲しいものの写真を持っていますが、私がそれを実装したとき、そのスタックオーバーフローの問題の画像ではどうなるのでしょうか? –
ここで私の答えを確認してください - https://stackoverflow.com/questions/45906041/how-can-i-create-space-between-table-view-cells-using-constraints/45908474#45908474。左右のスペースも簡単に処理できます。 –