How can I change text font in UIPickerView in iOS 7?

前端 未结 8 1609
清酒与你
清酒与你 2020-12-09 14:55

I was able to change my font color but I also need to change font size, how can I accomplish that? Here\'s my code for chaning the color,

 - (NSAttributedStr         


        
8条回答
  •  情话喂你
    2020-12-09 15:12

    Here's the Swift version tested on iOS8:

    Update in Swift for iOS8, you can add this to your delegate:

    func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView!) -> UIView {
    
        var pickerLabel = view as? UILabel;
    
        if (pickerLabel == nil)
        {
            pickerLabel = UILabel()
    
            pickerLabel?.font = UIFont(name: "Montserrat", size: 16)
            pickerLabel?.textAlignment = NSTextAlignment.Center
        }
    
        pickerLabel?.text = fetchLabelForRowNumber(row)
    
        return pickerLabel!;
    }
    

提交回复
热议问题