swift - Can we stop or remove animation effect on focus with UIButton and give other border effect tvOS -


in below delegate function trying did'nt desired result

override func didupdatefocusincontext(context: uifocusupdatecontext,withanimationcoordinator coordinator: uifocusanimationcoordinator) {     if (context.nextfocusedview == self) {         coordinator.addcoordinatedanimations({ () -> void in             self.animationdidstop(caanimation(), finished: true)             }, completion: { () -> void in          })      }     else {         // handle unfocused appearance changes          coordinator.addcoordinatedanimations({ () -> void in             self.animationdidstop(caanimation(), finished: true)             }, completion: { () -> void in          })     }     context.nextfocusedview?.layer.shadowoffset = cgsizezero     context.nextfocusedview?.layer.shadowopacity = 0.9;     context.nextfocusedview?.layer.shadowradius = 0;     context.nextfocusedview?.layer.shadowcolor= uicolor.orangecolor().cgcolor     context.previouslyfocusedview?.layer.shadowopacity = 0; } 

first of have set button type custom type. custom type no more system animations, have animations yourself.

then can implement didupdatefocusincontext method either in uiviewcontroller or can make own uibutton subclass if there more button types on single screen.

here code use in uibutton subclass. provide button enlargement along red border on focus , normal state on focus loss.

let scale = 1.1     layer.bordercolor = uicolor.redcolor().cgcolor  override func didupdatefocusincontext(context: uifocusupdatecontext, withanimationcoordinator coordinator: uifocusanimationcoordinator) {      if context.nextfocusedview == self {         coordinator.addcoordinatedanimations({ () -> void in              self.transform = cgaffinetransformmakescale(scale, scale)             self.layer.borderwidth = 2              }, completion: nil)     }     else {         coordinator.addcoordinatedanimations({ () -> void in              self.transform = cgaffinetransformidentity             self.layer.borderwidth = 0              }, completion: nil)     } } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -