Reputation: 51
I have this SpreadSheetView in my swift controller to show the data in a tabular form. The bottom corner radius are only being applied when I do not give padding to the view, but without the padding the table isn't expanding to the full height and is making the table scrollable vertically (which I do not want).
How I am initializing and setting it's height -
func setupSpreadsheetView() {
spreadSheetView = SpreadsheetView()
spreadSheetView.dataSource = self
spreadSheetView.delegate = self
spreadSheetView.showsVerticalScrollIndicator = false spreadSheetView.showsHorizontalScrollIndicator = false
spreadSheetView.bounces = false
spreadSheetView.gridStyle = .solid(width: 1.0, color: .fieldsBGColor) spreadSheetView.register(HeaderCell.self, forCellWithReuseIdentifier: String(describing: HeaderCell.self))
spreadSheetView.register(TextCell.self, forCellWithReuseIdentifier: String(describing: TextCell.self))
spreadSheetView.translatesAutoresizingMaskIntoConstraints = false
}
Inside calculating size of the cell function -
var ht = max(height, 35)
print("height of cell -> \(ht)")
finalHeight += ht
if row == data.count {
setSpreadsheetHeight()
print("height of sheet -> \(finalHeight)")
}
return ht
And finally setting the height of SpreadSheetView with additional 15 padding -
spreadSheetView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
spreadSheetView.heightAnchor.constraint(equalToConstant: finalHeight + 15)
])
spreadSheetView.layer.cornerRadius = 10
spreadSheetView.layer.masksToBounds = true
Final view with 15 padding (not showing bottom radius) -
View without 15 padding (shows radius but scrolls vertically which I do not intend to have) -
Removing the padding shows radius but if you look carefully, the content is just at the bottom and it scrolls vertically a bit.
Tried removing padding, changing height, but still bottom radius seems to be an issue.
Upvotes: 1
Views: 26