So I have a uipickerview with rows that only contain the number 0-24 and it looks a bit silly since the numbers are left aligned leaving a huge gap on the right of the picke
I know this question is not tagged for swift, but just in case somebody is looking for the Swift 3.0 version, here it is.
/* Called by the picker view when it needs the view to use for a given row in
a given component. If the previously used view (the view parameter) is adequate,
return that. If you return a different view, the previously used view is
released. The picker view centers the returned view in the rectangle for row.
*/
func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
var label = UILabel(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(300), height: CGFloat(37)))
let booking = self.bookingInfo[row] //bookingInfo is an array of elements
label.text = String(booking.BookingNumber) + String(booking.DateAndTime)
label.textAlignment = .left
return label
}