Ich möchte Text anordnen anordnen auf quadratische Form Ansichtsformat von Label Textzeile und Label hat einige kurze Wort und einige sind größer als andere Wort von Label Text, so sehen Sie bitte dieses Demo Image Sqaure shape ImageUILabel Textlinie als quadratische Form anordnen iOS
0
A
Antwort
0
Versuchen Sie, NSAttributedString zu verwenden, wünschen Sie Unterstützung für mehrere Schriftarten und Textgrößen und verwenden Sie \ n, um zur nächsten Zeile zurückzukehren.
NSDictionary *italicAttrs = @{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:16], NSForegroundColorAttributeName : [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0]};
NSDictionary *defaultAttrs = @{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:16], NSForegroundColorAttributeName : [UIColor blackColor]};
NSDictionary *arrowAttrs = @{NSFontAttributeName : [UIFont fontWithName:@"AlNile-Bold" size:20], NSForegroundColorAttributeName : [UIColor grayColor]};
NSMutableAttributedString *labelText = [[NSMutableAttributedString alloc] init];
NSAttributedString *from = [[NSAttributedString alloc] initWithString:@"From: " attributes:italicAttrs];
NSAttributedString *content = [[NSAttributedString alloc] initWithString:@"Me\n" attributes:defaultAttrs];
NSAttributedString *arrow = [[NSAttributedString alloc] initWithString:@"Ok" attributes:arrowAttrs];
[labelText appendAttributedString:from];
[labelText appendAttributedString:content];
[labelText appendAttributedString:arrow];
+0
ja sein, um mehrere Schriftarten und Textgröße mit NSMutableAttributedString aber zu machen. Ich möchte zufällige Schriftgröße und Schriftart Textgröße und nicht eine feste Textlänge machen seine Textlänge ist dynamisch, um mich zu empfehlen – Keyur
Verwandte Themen
- 1. quadratische Form verschwindet nicht, wenn auf
- 2. iOS - Unteransichten in Kreisform anordnen
- 3. Gewölbte UILabel in iOS
- 4. iOS Animieren UILabel erweitern
- 5. Quadratische Ansicht Gitter mit UIStackView - iOS
- 6. UILabel Platz als Porträt
- 7. Algorithmus, um eine quadratische Form in einem Bild zu finden?
- 8. iOS 9 Breaks Animationen von UILabel
- 9. iOS Constraints: wie UILabel Höhenbeschränkung Prioritäten geben
- 10. Quadratische Lese-Methode
- 11. iOS - UILabel + UIActivityIndicatorView innerhalb der UITableView-Abschnittsüberschrift
- 12. Wie fügen Sie UILabel (iOS Swift) ein?
- 13. Wie zeige ich Emoji in UILabel iOS
- 14. iOS: Setze Schriftgröße von UILabel programmatisch
- 15. UILabel gepunktete Linie Farbfehler in iOS 7.1
- 16. Wie UILabel Symbol mit Text in iOS
- 17. iOS - Automatisch schrumpfen UILabel mit Attributiertem Text
- 18. iOS - UIImage + UILabel Constraint Konflikt in UITableViewCell
- 19. Suchen nach Abschneiden in UILabel - iOS, Swift
- 20. Wie UILabel auf UIToolbar in iOS hinzufügen?
- 21. iOS (Swift) - autoresizing UILabel in CollectionView Zelle
- 22. Wie entfernen Einsätze in UILabel in iOS
- 23. ngCordova Kamera - Nehmen Sie quadratische Bilder wie Instagram (iOS)?
- 24. Begrenzen Sie das UILabel auf 500 Zeichen und dann kürzen Sie das UIlabel in IOS
- 25. Text auf einem UILabel in digitaler Form anzeigen?
- 26. iOS: Multipart Daten -Form Fehler
- 27. UILabel/NSTextView vs. CATextLayer
- 28. Bootstrap 3 quadratische Anzeige
- 29. UITextView verschiebt Text anders als UILabel
- 30. Benutzerdefinierte Schaltflächen neu anordnen
Was Sie tun möchten, ist ein Bild wie folgt zu zeichnen und dann laden Sie das Bild auf der Schaltfläche. –
[link] (http://i.stack.imgur.com/foDPR.png) @pRiva Bitte klicken Sie auf diesen Link um das Demo-Bild zu öffnen – Keyur
Ein Label hat nur 1 Font. Mehrere Schriftarten erfordern mehrere Etiketten. Es ist nicht möglich, eine Benutzeroberfläche wie die Demo mit Labels zu erstellen. U kann ein Bild zeichnen und das Bild auf einem UII-Bild hinzufügen. Wenn Sie Ihre Etiketten sortieren möchten, können Sie die Stapelansicht verwenden und einige Einschränkungen verwenden. Wenn du das willst, kann ich dir dabei helfen. –