I use Swift 2 and Xcode 7.
I would like to blur in the background of my UITextField. I have not found a property backgroundView
. Only background
(for background image) or backgroundColor
.
I would have come to add a view in background. But I do not know how to make a UITextField.
Do you have a solution ?
You can set the background color to white, and change its alpha value:
Probably not exactly what you asked, but much easier to implement.
You can only add some kind of view to make it a blur view. Now the problem is that textfields don't have a backgroundView property but they do have a background property where we can set an
UIImage
. So we can make aUIImage
from aUIView
tooThis method will create a UIImage for the UIView passed.
Now we will use a
UIBlurEffect
andUIVisualEffectView
which are available for iOS 8+Here is the screenshot attached
Hope this helps
You can always put a transparent text field on top of another view. If that view happens to have the same size as the text field, it'll look just like the background view of the text field. You could even make the text field a subview of the "background" view, so that you can move them around together more easily.