iOS blur effect to ImageView with Swift
I am trying to make simple iOS app. I need to make image view with blur effect.
I found this code on Stack Overflow:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
required init(coder aDecoder: NSCoder!){
super.init(coder: aDecoder)
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
And I need to connect this class to my image_view
, but I don't know how to do it.
I try to do it in my view_did_load
function in my ViewController
(image_view
is a outlet)
override func viewDidLoad() {
super.viewDidLoad()
image_view = BlurImageView()
}
but NSCoder
required... What is it? maybe my way is a wrong way?
ios swift uiimageview blur
add a comment |
I am trying to make simple iOS app. I need to make image view with blur effect.
I found this code on Stack Overflow:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
required init(coder aDecoder: NSCoder!){
super.init(coder: aDecoder)
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
And I need to connect this class to my image_view
, but I don't know how to do it.
I try to do it in my view_did_load
function in my ViewController
(image_view
is a outlet)
override func viewDidLoad() {
super.viewDidLoad()
image_view = BlurImageView()
}
but NSCoder
required... What is it? maybe my way is a wrong way?
ios swift uiimageview blur
Added blur effect with stackoverflow.com/questions/24067719/…
– mr_ivan777
Aug 14 '14 at 21:10
add a comment |
I am trying to make simple iOS app. I need to make image view with blur effect.
I found this code on Stack Overflow:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
required init(coder aDecoder: NSCoder!){
super.init(coder: aDecoder)
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
And I need to connect this class to my image_view
, but I don't know how to do it.
I try to do it in my view_did_load
function in my ViewController
(image_view
is a outlet)
override func viewDidLoad() {
super.viewDidLoad()
image_view = BlurImageView()
}
but NSCoder
required... What is it? maybe my way is a wrong way?
ios swift uiimageview blur
I am trying to make simple iOS app. I need to make image view with blur effect.
I found this code on Stack Overflow:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
required init(coder aDecoder: NSCoder!){
super.init(coder: aDecoder)
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
And I need to connect this class to my image_view
, but I don't know how to do it.
I try to do it in my view_did_load
function in my ViewController
(image_view
is a outlet)
override func viewDidLoad() {
super.viewDidLoad()
image_view = BlurImageView()
}
but NSCoder
required... What is it? maybe my way is a wrong way?
ios swift uiimageview blur
ios swift uiimageview blur
edited Nov 29 '18 at 11:41
Shruti Thombre
8311823
8311823
asked Aug 14 '14 at 20:45
mr_ivan777mr_ivan777
1861717
1861717
Added blur effect with stackoverflow.com/questions/24067719/…
– mr_ivan777
Aug 14 '14 at 21:10
add a comment |
Added blur effect with stackoverflow.com/questions/24067719/…
– mr_ivan777
Aug 14 '14 at 21:10
Added blur effect with stackoverflow.com/questions/24067719/…
– mr_ivan777
Aug 14 '14 at 21:10
Added blur effect with stackoverflow.com/questions/24067719/…
– mr_ivan777
Aug 14 '14 at 21:10
add a comment |
2 Answers
2
active
oldest
votes
You need to make your image_view
an instance of BlurImageView
, so in your view controller and where your image_view
is an outlet, you need to make it an instance of BlurImageView
and not an instance of an UIImageView
.
add a comment |
You don't need it. The reason why you're not seeing results is because you're attempting to initialize the class from a different initializer than the one you setup.
Try:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
override init() {
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f25317292%2fios-blur-effect-to-imageview-with-swift%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to make your image_view
an instance of BlurImageView
, so in your view controller and where your image_view
is an outlet, you need to make it an instance of BlurImageView
and not an instance of an UIImageView
.
add a comment |
You need to make your image_view
an instance of BlurImageView
, so in your view controller and where your image_view
is an outlet, you need to make it an instance of BlurImageView
and not an instance of an UIImageView
.
add a comment |
You need to make your image_view
an instance of BlurImageView
, so in your view controller and where your image_view
is an outlet, you need to make it an instance of BlurImageView
and not an instance of an UIImageView
.
You need to make your image_view
an instance of BlurImageView
, so in your view controller and where your image_view
is an outlet, you need to make it an instance of BlurImageView
and not an instance of an UIImageView
.
answered Aug 14 '14 at 20:52
BHendricksBHendricks
3,25052252
3,25052252
add a comment |
add a comment |
You don't need it. The reason why you're not seeing results is because you're attempting to initialize the class from a different initializer than the one you setup.
Try:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
override init() {
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
add a comment |
You don't need it. The reason why you're not seeing results is because you're attempting to initialize the class from a different initializer than the one you setup.
Try:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
override init() {
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
add a comment |
You don't need it. The reason why you're not seeing results is because you're attempting to initialize the class from a different initializer than the one you setup.
Try:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
override init() {
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
You don't need it. The reason why you're not seeing results is because you're attempting to initialize the class from a different initializer than the one you setup.
Try:
class BlurImageView: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
}
override init() {
var blur:UIBlurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView:UIVisualEffectView = UIVisualEffectView (effect: blur)
effectView.frame = frame
addSubview(effectView)
}
}
answered Aug 14 '14 at 20:51
jakenbergjakenberg
1,8041535
1,8041535
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f25317292%2fios-blur-effect-to-imageview-with-swift%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Added blur effect with stackoverflow.com/questions/24067719/…
– mr_ivan777
Aug 14 '14 at 21:10