2016-05-03 7 views
1

Ich möchte PNG-Bild zwischen meinem Text von einem Etikett enthalten. wie damit in objective-c verfahren wird.Wie PNG-Bild zwischen Text eines Labels enthalten

+1

versuchen Sie dieses: http://stackoverflow.com/questions/19318421/how-to-embed-small-icon-in-uilabel – sonique

+1

danke das hat mein Problem gelöst :-) – raj

Antwort

1

Dies ist die Antwort, falls jemand es nützlich finden ----->

NSTextAttachment *attachment = [[NSTextAttachment alloc] init]; 
    attachment.image = [UIImage imageNamed:@"Attach-52.png"]; 

    NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:attachment]; 

    NSMutableAttributedString *myString= [[NSMutableAttributedString alloc] initWithString:@"My label text"]; 
    [myString appendAttributedString:attachmentString]; 

    myLabel.attributedText = myString; 

Ebenso können Sie PNG-Bild durch NSAttributedString hinzufügen.