¿Es posible stikethrough
a UILabel
en absoluto? Parece que no puedo encontrar la opción ...UILabel Strikethrough
Respuesta
Esta es una pregunta anterior y la información más reciente está disponible.
Comenzando en iOS 6, tenemos NSAttributedString.
Para iOS 6 pre, me gustaría ver TTTAttributedLabel
iPhone no es compatible con cadenas atribuidas (que normalmente es la forma en que haría esto en Cocoa), por lo que no creo que sea posible.
Puede crear la subclase UILabel
y dibujar el strikethrough
usted mismo. También he visto a algunas personas usar UIWebView
para hacer este tipo de cosas, pero eso me parece exagerado.
Se puede crear otra UILabel por encima de la etiqueta y usar un guión carácter:
label.text = @"––––––––––––––––––";
Advertencia: trabaja con Helvetica (por defecto del sistema). Es posible que no funcione con otras fuentes.
UIView* slabel = [[UIView alloc] initWithFrame:CGRectMake(label.frame.origin.x, label.frame.origin.y+10, label.frame.size.width, 2)];
[self addSubview:slabel];
[slabel setBackgroundColor:label.textColor];
Puede agregar una vista sobre UILabel y darle un estilo con propiedades de etiqueta.
NSAttributedString *str=[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%.2f", productOne.priceBefore] attributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle)}];
cell.priceBefore.attributedText = str;
- 1. Efecto StrikeThrough en un TextBlock
- 2. Multiline UILabel?
- 3. UILabel - autoresize
- 4. Subclase UILabel
- 5. Autosize UILabel
- 6. Opacidad diferente para UILabel y el texto de UILabel
- 7. Obtener ancho de la última línea de UILabel UILabel
- 8. UIPickerView con Multiline UILabel
- 9. UILabel no está actualizando
- 10. truncamiento de cola uilabel
- 11. UILabel y fuentes
- 12. Expansión Multiline UILabel
- 13. ¿Formatear UILabel con viñetas?
- 14. Sombra interior en UILabel
- 15. UILabel Over UISlider Thumb
- 16. iPhone UILabel sizeWithFont:
- 17. Haciendo UILabel táctil
- 18. UILabel/NSTextView vs. CATextLayer
- 19. Pinch-to-zoom UILabel
- 20. UILabel UITextField UITextView
- 21. ¿Animar a UILabel pulsante?
- 22. UILabel multilínea con ajustesFontSizeToFitWidth
- 23. contenidos UILabel Centro
- 24. ¿Dimensionando un UILabel para encajar?
- 25. Animate UILabel no es liso
- 26. UILabel y numberOfLines y sizeToFit:
- 27. tamaño para adaptarse a UILabel
- 28. UILabel Alinear texto al centro
- 29. Cadena Html configurada en UILabel
- 30. crear mediante programación un UILabel
Gracias, poco basura sin embargo! blimin Apple! –
Al iniciar iOS 6, es compatible con NSAttributedString. Ver mi publicación – Stephen