iOS AssistiveTouch slow animation when using custo

2019-06-21 04:42发布

问题:

I'm building an custom keyboard, everything is fine now, except when i'm using AssistiveTouch during my custom keyboard is enabled, the animation of AssistiveTouch is little bit laggy (slow zoom in , zoom out) when tap to open it.

I tested on iPhone 4s and iPhone 6 , same trouble, so i think is not about device hardware or resource consume.

Anyone having same trouble or know reason? and how to solve it ?

回答1:

I found reason by myself. that because of shadow. i added shadow for each button, after remove shadow, the lag didn't appear anymore.

so anyone suggest some better way to add shadow to button without laggy?

this is my way to add shadow to button:

button.layer.masksToBounds = false
        button.layer.shadowColor = UIColor(rgb: 0x000000, alpha: 0.5).CGColor
        button.layer.shadowOpacity = 1.0
        button.layer.shadowRadius = 0
        button.layer.shadowOffset = CGSizeMake(0, 1.0)


回答2:

I found the answer to this after a little time of trying. I found that really you have to add shadow to your buttons. if you are using Xcode 6 or 7 then when you go to your storyboard, select the button and select the attribute inspector and there will be a option of shadow. select it and you will get it.