tableViewが空の場合はソリューションを作成し、ラベルは「データなし」、それ以外の場合はコンテンツを表示します。しかし、私は一緒に背景画像とラベルを表示することができません。私が間違っていることは何ですか?tableviewが空の場合はラベルと画像を表示
これは私がそれを行う方法です。
var numOfSections: Int = 0
if reviewsArray.count != 0{
tableView.separatorStyle = .singleLine
numOfSections = reviewsArray.count
}
else{
let noDataLabel: UILabel = UILabel(frame: CGRect(0, 0, tableView.bounds.size.width, tableView.bounds.size.height))
noDataLabel.text = "No data available"
noDataLabel.textColor = UIColor.black
noDataLabel.textAlignment = .center
tableView.backgroundView = noDataLabel
tableView.separatorStyle = .none
}
とのviewDidLoadで、私がぼやけて背景画像を追加します。
let blurredBackgroundView = BlurredBackgroundView(frame: .zero)
tableView.backgroundView = blurredBackgroundView
tableView.separatorEffect = UIVibrancyEffect(blurEffect: blurredBackgroundView.blurView.effect as! UIBlurEffect)
任意のサードパーティのライブラリを提案しないでください:)
ラベルで背景イメージを上書きしています。背景イメージとラベルで新しい 'UIView'を作成する必要があります。 'reviewArray'が空のときは、' tableView.background'として設定します。 – Eeshwar