¿Alguien sabe si es posible cambiar la fuente y/o el color de los elementos individuales de UIPickerView?UIPickerView Font
Respuesta
Sí, es posible. Para hacerlo, debe implementar el método pickerView:viewForRow:forComponent:reusingView:
en el delegado del selector: cree allí la instancia UILabel
y configúrela con los atributos que desee.
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel* tView = (UILabel*)view;
if (!tView){
tView = [[UILabel alloc] init];
// Setup label properties - frame, font, colors etc
...
}
// Fill the label text here
...
return tView;
}
Gracias, funciona bien. –
Para esto, simplemente iría con cadenas atribuidas.
implementar este método es su delegado:
- (NSAttributedString *)pickerView:(UIPickerView *)pickerView
attributedTitleForRow:(NSInteger)row
forComponent:(NSInteger)component
Probé esto; no funcionó (iOS 9.3), aunque se llamaba. –
Me funcionó con iOS 9.3. ¿Estás seguro de que estás creando NSAttributedString correctamente? – Rickster
Seguramente debo haber estado haciendo algo mal, aunque no pude ver qué. Al final, hice lo sugerido en las otras respuestas y devolví una etiqueta configurada. –
- 1. Deshabilitar UIPickerView
- 2. UIPickerView reloadData
- 3. ¿Por qué no definir font-weight o font-style en @ font-face, Font Squirrel?
- 4. Center UIPickerView Text
- 5. UIPickerView para países disponibles
- 6. UIPickerView con Multiline UILabel
- 7. Color de fila UIPickerView
- 8. UIPickerView muestra títulos incorrectos
- 9. Columna UIPickerView Títulos
- 10. Ejemplo programático UIPickerView?
- 11. Recargar datos en UIPickerView
- 12. UIPIckerView en UIPopoverController
- 13. UIPickerView con NSDictionary
- 14. Usando @ font-face para Segoe UI font
- 15. font-size: 62,5% vs. font-size: 10px
- 16. cómo agregar UIPickerView en UIActionSheet
- 17. Personalizar UIPickerView (fondo y espaciado)
- 18. ¿Cómo detectar cambios en UIPickerView?
- 19. UIPickerView desactivar selección de fila
- 20. body {font-size: 100.01%; } vs body {font-size: 100%; }?
- 21. @ font-face vs Cufon
- 22. @ font-face no funciona
- 23. CSS font-face emite
- 24. reading windows font
- 25. Cufón font security
- 26. Eclipse Indigo Font Changed
- 27. malayalam font en android?
- 28. ¿Cómo funciona @ font-face?
- 29. Emacs buffer-local font
- 30. Precargando fuentes @ font-face?
Sí !! ¡Gracias, funciona genial! – LilMoke
Genial, pero ¿cómo sabrías los atributos predeterminados de Label sin adivinar? –