I need to set the leading and trailing for the UITableViewCell which is under UITableViewController.
Specific class for the UITableViewCell , I have added below code.
override func layoutSubviews() {
self.frame = CGRect(x: 10.0, y: self.frame.origin.y, width: 390.0, height: self.frame.size.height)
super.layoutSubviews()
}
The above leaves spaces in leading and trailing. But the problem when i tested in iPhone 5s and 4 simulator it leads to horizontal scrolling.
I taught the problem due to the constant width. So I have got specific label field width from the UITableViewcell and subtracted by 10.0
I have tried the below code for the width issue. But , Nothing worked out.
func setFrame(x: CGFloat, y: CGFloat , width: CGFloat , height: CGFloat ) {
let newX = x.isNaN ? self.frame.origin.x : x
let newY = y.isNaN ? self.frame.origin.y : y
let newWidth = width.isNaN ? self.bounds.size.width : width
let newHeight = height.isNaN ? self.bounds.size.height : height
self.frame = CGRect(x: newX, y: newY, width: newWidth, height: newHeight)
}
override func layoutSubviews() {
let width = (greetingLabel.bounds.size.width - 10.0)
setFrame(x: 5.0, y: 5.0, width:width, height: self.frame.height)
}
I have tried keeping all the fields inside View, but the UI doesn't look good.
Please provide me some input how set the leading and trailing for the UITableViewCell.
I want to achieve like this screen: