¿Cómo puedo cambiar el color del color del botón UIActionSheet?Color del botón UIActionSheet
Respuesta
iOS 8 (UIAlertController)
Es super fácil de hacer si usted está utilizando una UIAlertController. Simplemente cambie el color del tinte en la vista del UIAlertController.
[alertController.view setTintColor:[UIColor red];
iOS 7 (UIActionSheet)
puedo cambiar el color del texto con éxito mediante el uso de este método simple.
- (void) changeTextColorForUIActionSheet:(UIActionSheet*)actionSheet {
UIColor *tintColor = [UIColor redColor];
NSArray *actionSheetButtons = actionSheet.subviews;
for (int i = 0; [actionSheetButtons count] > i; i++) {
UIView *view = (UIView*)[actionSheetButtons objectAtIndex:i];
if([view isKindOfClass:[UIButton class]]){
UIButton *btn = (UIButton*)view;
[btn setTitleColor:tintColor forState:UIControlStateNormal];
}
}
}
Asegúrese de ejecutar este DESPUÉS se llama
[actionSheet showInView];
Si llama antes [showInView], todos los botones, pero será de color del botón de cancelación. ¡Espero que esto ayude a alguien!
Desafortunadamente, sin utilizar las API no documentadas, no hay forma oficial de cambiar el color del botón en una Hoja de UIAction. Puede personalizar esto si subclase el control UIActionSheet.
ver este ejemplo: http://blog.corywiles.com/customizing-uiactionsheet-buttons
He creado UICustomActionSheet clase hija, que permite personalizar las fuentes, colores e imágenes de botones dentro de UIActionSheet. Está absolutamente seguridad para appstore, se puede encontrar el código de esta clase en el siguiente enlace:
https://github.com/gloomcore/UICustomActionSheet
disfrutar de ella!
Podemos usar imágenes de fondo para hacerlo. Creo que es la manera más fácil.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Actionsheet" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet addButtonWithTitle:@"Button 1"]; //Blue color
[actionSheet addButtonWithTitle:@"Button 2"];
[actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet addButtonWithTitle:nil];
[actionSheet setCancelButtonIndex:2];
[actionSheet setDestructiveButtonIndex:1];
[actionSheet showInView:self.view];
UIButton *button = [[actionSheet subviews] objectAtIndex:1];
UIImage *img = [button backgroundImageForState:UIControlStateHighlighted];//[UIImage imageNamed:@"alert_button.png"];
[button setBackgroundImage:img forState:UIControlStateNormal];
Se puede lograr fácilmente mediante el uso siguiente código
de Apple
UIActionSheetDelegate
documentación del protocolo
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
for (UIView *_currentView in actionSheet.subviews)
{
if ([_currentView isKindOfClass:[UIButton class]])
{
UIButton *button = (UIButton *)_currentView;
[button setTitleColor:YOUR_COLOR forState:UIControlStateNormal];
}
}
}
- 1. ¿Cómo cambiar la secuencia del botón en UIActionsheet en iPhone?
- 2. UIActionSheet botón de cancelación comportamiento extraño
- 3. iPhone SDK - UIActionSheet - Títulos de botón dinámico
- 4. ¿Cómo codigo un botón verde en UIActionSheet?
- 5. ¿Cómo deshabilitar el botón en UIActionSheet?
- 6. Cambio del color del botón mediante programación
- 7. ActionBarSherlock ¿Cambia el color del botón Atrás?
- 8. Cambiar el color del botón en AlertDialog
- 9. UIActionSheet del iPad mostrando varias veces
- 10. ¿Cómo agregar un botón a una hoja de UIActionSheet existente?
- 11. iPad UIActionSheet - No muestra el último botón agregado
- 12. UIActionSheet en el iPad no muestra el botón cancelar
- 13. Cambiar el color del texto del botón cuando se selecciona
- 14. ¿Cómo puedo cambiar el color predeterminado del botón en iPhone?
- 15. cómo obtener el color de fondo del botón en Android?
- 16. Color del botón en la barra de navegación - iPhone
- 17. ¿Cómo cambiar el color del botón de alternar?
- 18. ¿Cómo cambio el color del texto de un botón?
- 19. Cambio de color del botón al pasar el mouse
- 20. Cambiar el color del botón en la celda DataGridView
- 21. cambiar el color del botón de texto cuando se presiona
- 22. Botón personalizado de Android; cambiar el color del texto
- 23. Borrar el color del botón en el campo de texto
- 24. ¿Cómo establecer el color del texto en el botón Enviar?
- 25. Múltiples botones rojos/destructivos UIActionSheet
- 26. Cómo establecer el color del botón de un JButton (no color de fondo)
- 27. jQuery Mobile botón color de fondo
- 28. Android: iOS UIActionSheet equivalente
- 29. Cómo cerrar UIActionSheet automáticamente
- 30. Mostrando una UIActionSheet
Esta debería ser la respuesta seleccionada. Bien hecho. – dclowd9901
@ dclowd9901 ¡Gracias! ;) – Rymnel
Gracias - funciona bien en iOS7. – kmorris