ios - UILabel with Multiple links -
hello trying tappable uilabel similar facebook's text, label's text similar
"you, steve , 50 others this."
where "you", "steve" , "50 others" should tappable separately.
i trying luck nsattributedstring not helping me, can help me find way ?
try this, it's not label it's textview.
nsmutableattributedstring * string = [[nsmutableattributedstring alloc] initwithstring:@"firstsecond"]; [string addattribute:nsforegroundcolorattributename value:[uicolor redcolor] range:nsmakerange(0,5)]; [string addattribute:nsforegroundcolorattributename value:[uicolor greencolor] range:nsmakerange(5,6)]; //[string addattribute:nsunderlinestyleattributename value:[nsnumber numberwithint:10] range:nsmakerange(0,5)]; [string addattribute:nslinkattributename value:[nsurl urlwithstring:@"http://www.google.co.in"] range:nsmakerange(0,5)]; [string addattribute:nslinkattributename value:[nsurl urlwithstring:@"http://www.yahoo.com"] range:nsmakerange(5,6)]; self.txtview.attributedtext=string; self.txtview.scrollenabled = no; self.txtview.editable = no; self.txtview.textcontainer.linefragmentpadding = 0; self.txtview.textcontainerinset = uiedgeinsetsmake(0, 0, 0, 0); self.txtview.delegate = self; } - (bool)textview:(uitextview *)textview shouldinteractwithurl:(nsurl *)url inrange: (nsrange)characterrange { homecoming yes; }
ios objective-c uilabel nsattributedstring
No comments:
Post a Comment