給UIButton設置圓角和陰影,關鍵點是shadowOpacity不能為0
private lazy var <#name#>: UIButton = {
let button = UIButton(type: .custom)
button.layer.cornerRadius = 20
button.layer.shadowColor = UIColor.black.cgColor
button.layer.shadowRadius = 2
button.layer.shadowOffset = CGSize(width: 2, height: 2)
button.layer.shadowOpacity = 0.1
return button
}()
無論是UICollectionView還是UITableView要想contentInset表現的如預期那樣考慮一下設置
if #available(iOS 11.0, *) {
collectionView.contentInsetAdjustmentBehavior = .never
} else {
automaticallyAdjustsScrollViewInsets = false
}
記一次UITableView 樣式為group 設置了sectionHeader/sectionFooder卡頓 解決方法 需要設置以下屬性
tableView.estimatedSectionHeaderHeight = 0
tableView.estimatedSectionFooterHeight = 0
navigationbar設置titleview 在iOS11以下尺寸正常展示
class <#name#>: UIView {
let contentSize: CGSize
override var intrinsicContentSize: CGSize {
if #available(iOS 11, *) {
return UIView.layoutFittingExpandedSize
} else {
return contentSize
}
}
override init(frame: CGRect) {
contentSize = frame.size
super.init(frame: frame)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}