swift - How to set an action to a part of UILabel? -


i'd set action "part" of uilabel not of uilabel, "term of service" of attached picture. using storyboard. now, i'm thinking cover uibutton on part of uilabel. however, troublesome adjust part of label button @ layout(iphone 5, 6 , 6 plus) autolayout. if know better way, please tell me. thank kindness.

enter image description here

i'd recommend using uitextview nsattributedstring. range of text looking for, , add button subview view.

nsrange termsofservicerange = [self.termsofusetextview.text rangeofstring:@"terms of service"]; self.termsofusetextview.selectedrange = termsofservicerange; uitextrange *termsofservicetextrange = [self.termsofusetextview selectedtextrange]; cgrect termsofserviceframe = [self.termsofusetextview firstrectforrange:termsofservicetextrange]; cgrect convertedframe = [self.view convertrect:termsofserviceframe fromview:self.termsofusetextview];  uibutton *termsofservicebutton = [[uibutton alloc]initwithframe:convertedframe]; [termsofservicebutton setbackgroundcolor:[uicolor clearcolor]]; [termsofservicebutton addtarget:self action:@selector(termsofservicebuttonpressed:) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview:termsofservicebutton]; [self.view bringsubviewtofront:termsofservicebutton]; 

Comments

Popular posts from this blog

javascript - Trigger mouseenter when an animated element touches mouse -

json - Zend error Connection -

java - Using Spring @Transactional with a combination of readOnly and write, when does this entity get committed? -