animation - animate text alignment for UILabel in swift -


so question more of challenge in end. maybe im going wrong direction though maybe ask ideas.

the context:

i have set of string (place names) , want suggest answers based on user inputs in uitextview.

the method:

i used combination of 2 uilabels , 1 uitextview achieve working results: suggestionlabel in background, searchlabel in middle, , searchinput text view on foreground. textview enables interaction text's alpha set 0 (i didn't want consume time padding , insets relative various screen size , autolayout constraints have). when typing, changes reflected on searchlabel, , suggestion based on inputs on suggestionlabel.

the goal:

it's visual goal. when user select place based on suggestion, place's profile fades in , title set @ exact same place search text. (all of serve looking transition).

the challenge:

the search input, label , place's profile title have centered (im speaking text alignment here). make work different layer of text, used set of auto layout constraints blocks centered in views, dynamic width, , original text alignment set .left

having alignment set .center breaks text layers perfect overlap. so, though keeping way , make transition .left alignement .center when users validate choices.

my problem textalignment doesn't seems can smoothly animate. wondering if there trick of sort use :)

thanks idea come with.

im not sure it's relevant here code wrote:

func textviewdidchange(textview: uitextview) { //handle text changes here          displaysearch.text = textview.text         displaysearch.textalignment = nstextalignment.left         displaysearch.font = uifont(name: searchview.font.fontname, size: 23)          if suggestview.text!.rangeofstring(searchview.text) != nil{             println("exists")         }         else{             suggestview.text = ""         }          //user input         let scope = self.searchview.text          //scanning suggestion dict         for(var = 0; < dict.count; i++){             let stringon = dict[i]["place"] as! string             println(stringon)              if let range = stringon.rangeofstring(scope.lowercasestring) {                 if range.startindex == stringon.startindex {                     suggestview.text = stringon.capitalizedstring                     searchview.text = searchview.text.capitalizedstring                     suggestview.textalignment = nstextalignment.left                     suggestview.font = uifont(name: searchview.font.fontname, size: 23)                     suggestview.textcolor = uicolor.graycolor()                 }             }         }     }   func textview(textview: uitextview, shouldchangetextinrange range: nsrange, replacementtext text: string) -> bool {         if(text == "\n") {             textview.resignfirstresponder()             //animate text alignment             return false         }         return true     } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -