Environment:
Hi,
I can't seem to set the alignment of a LabelRow to center. I'm using the following code:
<<< LabelRow("TEST") {
$0.title = "Test label"
$0.cellUpdate { cell, row in
cell.textLabel?.textAlignment = .center
cell.textLabel?.textColor = .white
cell.backgroundColor = UIColor(red: 255/255, green: 65/255, blue: 65/255, alpha: 1.0)
}
}
I've read on StackOverflow that this should work but nothing is happening on the label. I've checked the frame of the label and it's the size of the text. I've tried to set the cell frame and textLabel frame to something different but that's also not working.
Hi @Tripwire999 , you should change the table view cell style to get this layout as code below shows...
<<< LabelRow () {
$0.title = "LabelRow"
$0.cellStyle = .default
}
.cellUpdate({ (cell, row) in
cell.textLabel?.textAlignment = .center
})
Regards
Hi,
Sorry for the late reply but it's still not working for me. I've changed some code here is a sample of what i'm using now which is not working:
let endDateTimeError: LabelRow = LabelRow()
endDateTimeError.tag = "endDateTimeErrorRow"
endDateTimeError.title = "Eindtijd kan niet voor begintijd liggen"
endDateTimeError.cell.backgroundColor = timeErrorBackgroundColor
endDateTimeError.cellStyle = .default
endDateTimeError.cellUpdate { cell, row in
cell.textLabel?.textAlignment = .center
cell.textLabel?.textColor = timeErrorTextColor
}
endDateTimeError.hidden = .function([""], { form -> Bool in
return employee.endTime! > employee.startTime!
})
section <<< endDateTimeError
hi,
I have the same problem, alignemte right not working
Here is the code, i use to validate TextRow
.onRowValidationChanged { cell, row in
let rowIndex = row.indexPath!.row
while row.section!.count > rowIndex + 1 && row.section?[rowIndex + 1] is LabelRow {
row.section?.remove(at: rowIndex + 1)
}
if !row.isValid {
for (index, validationMsg) in row.validationErrors.map({ $0.msg }).enumerated() {
let labelRow = LabelRow() {
$0.title = validationMsg
$0.cell.height = { 30 }
}.cellUpdate { cell, row in
cell.textLabel?.textColor = .red //THIS WORKS
cell.textLabel?.textAlignment = .right //NOT WORKING
}
row.section?.insert(labelRow, at: row.indexPath!.row + index + 1)
}
}
}
@marioGusmao I think that won't work with the default cellStyle. I also don't know what exactly you want to accomplish. Please search in other issues and StackOverFlow for help
Most helpful comment
Hi @Tripwire999 , you should change the table view cell style to get this layout as code below shows...
Regards