How to place UIImageView over the navigationBar
I'm trying to get the black circle to go on top of the red Nav Bar but am lost for how to achieve. This is what I have so far:
override func viewDidAppear(_ animated: Bool) {
//Adding the button
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
super.view.addSubview(buttonView)
}
ios iphone swift
add a comment |
I'm trying to get the black circle to go on top of the red Nav Bar but am lost for how to achieve. This is what I have so far:
override func viewDidAppear(_ animated: Bool) {
//Adding the button
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
super.view.addSubview(buttonView)
}
ios iphone swift
is that a navigation bar or a tableViewHeader?
– Joshua
Nov 26 '18 at 0:05
it's a Navigation bar. I'm reading around and some say that it has to do with the scope of the view. If that's the case, how can I get it so that the top half of the circle fades in as a UIimage whenever the tableview is scrolled to the top? I'm assuming you'd have to have another copy of the image and just crop, but what would the animation look like and how would I detect the bar expanding? At the moment, the circle scrolls away with the table, which I actually think is cool, so as long as I can get the entire thing to show when I'm positioned the same as the image, that'd be fine with me.
– teachMeSenpai
Nov 26 '18 at 0:13
add a comment |
I'm trying to get the black circle to go on top of the red Nav Bar but am lost for how to achieve. This is what I have so far:
override func viewDidAppear(_ animated: Bool) {
//Adding the button
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
super.view.addSubview(buttonView)
}
ios iphone swift
I'm trying to get the black circle to go on top of the red Nav Bar but am lost for how to achieve. This is what I have so far:
override func viewDidAppear(_ animated: Bool) {
//Adding the button
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
super.view.addSubview(buttonView)
}
ios iphone swift
ios iphone swift
asked Nov 25 '18 at 23:35
teachMeSenpaiteachMeSenpai
476
476
is that a navigation bar or a tableViewHeader?
– Joshua
Nov 26 '18 at 0:05
it's a Navigation bar. I'm reading around and some say that it has to do with the scope of the view. If that's the case, how can I get it so that the top half of the circle fades in as a UIimage whenever the tableview is scrolled to the top? I'm assuming you'd have to have another copy of the image and just crop, but what would the animation look like and how would I detect the bar expanding? At the moment, the circle scrolls away with the table, which I actually think is cool, so as long as I can get the entire thing to show when I'm positioned the same as the image, that'd be fine with me.
– teachMeSenpai
Nov 26 '18 at 0:13
add a comment |
is that a navigation bar or a tableViewHeader?
– Joshua
Nov 26 '18 at 0:05
it's a Navigation bar. I'm reading around and some say that it has to do with the scope of the view. If that's the case, how can I get it so that the top half of the circle fades in as a UIimage whenever the tableview is scrolled to the top? I'm assuming you'd have to have another copy of the image and just crop, but what would the animation look like and how would I detect the bar expanding? At the moment, the circle scrolls away with the table, which I actually think is cool, so as long as I can get the entire thing to show when I'm positioned the same as the image, that'd be fine with me.
– teachMeSenpai
Nov 26 '18 at 0:13
is that a navigation bar or a tableViewHeader?
– Joshua
Nov 26 '18 at 0:05
is that a navigation bar or a tableViewHeader?
– Joshua
Nov 26 '18 at 0:05
it's a Navigation bar. I'm reading around and some say that it has to do with the scope of the view. If that's the case, how can I get it so that the top half of the circle fades in as a UIimage whenever the tableview is scrolled to the top? I'm assuming you'd have to have another copy of the image and just crop, but what would the animation look like and how would I detect the bar expanding? At the moment, the circle scrolls away with the table, which I actually think is cool, so as long as I can get the entire thing to show when I'm positioned the same as the image, that'd be fine with me.
– teachMeSenpai
Nov 26 '18 at 0:13
it's a Navigation bar. I'm reading around and some say that it has to do with the scope of the view. If that's the case, how can I get it so that the top half of the circle fades in as a UIimage whenever the tableview is scrolled to the top? I'm assuming you'd have to have another copy of the image and just crop, but what would the animation look like and how would I detect the bar expanding? At the moment, the circle scrolls away with the table, which I actually think is cool, so as long as I can get the entire thing to show when I'm positioned the same as the image, that'd be fine with me.
– teachMeSenpai
Nov 26 '18 at 0:13
add a comment |
1 Answer
1
active
oldest
votes
Try this one. This should put the image on top of the nav bar.
override func viewDidAppear(_ animated: Bool) {
//Adding the button
navigationController?.navigationBar.addSubview(buttonView)
let navBar = navigationController?.navigationBar
// use this navBar to set your framing and constraints
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
}
hey thanks for your comment! your code solved the issue of the image not showing over the navigation bar, but now the image is huge and I can't resize or change the coordinates of the image! I'm trying to manipulate it through CGRect....
– teachMeSenpai
Nov 26 '18 at 21:53
figured it out. Thanks mate
– teachMeSenpai
Nov 28 '18 at 18:24
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%2f53473083%2fhow-to-place-uiimageview-over-the-navigationbar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this one. This should put the image on top of the nav bar.
override func viewDidAppear(_ animated: Bool) {
//Adding the button
navigationController?.navigationBar.addSubview(buttonView)
let navBar = navigationController?.navigationBar
// use this navBar to set your framing and constraints
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
}
hey thanks for your comment! your code solved the issue of the image not showing over the navigation bar, but now the image is huge and I can't resize or change the coordinates of the image! I'm trying to manipulate it through CGRect....
– teachMeSenpai
Nov 26 '18 at 21:53
figured it out. Thanks mate
– teachMeSenpai
Nov 28 '18 at 18:24
add a comment |
Try this one. This should put the image on top of the nav bar.
override func viewDidAppear(_ animated: Bool) {
//Adding the button
navigationController?.navigationBar.addSubview(buttonView)
let navBar = navigationController?.navigationBar
// use this navBar to set your framing and constraints
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
}
hey thanks for your comment! your code solved the issue of the image not showing over the navigation bar, but now the image is huge and I can't resize or change the coordinates of the image! I'm trying to manipulate it through CGRect....
– teachMeSenpai
Nov 26 '18 at 21:53
figured it out. Thanks mate
– teachMeSenpai
Nov 28 '18 at 18:24
add a comment |
Try this one. This should put the image on top of the nav bar.
override func viewDidAppear(_ animated: Bool) {
//Adding the button
navigationController?.navigationBar.addSubview(buttonView)
let navBar = navigationController?.navigationBar
// use this navBar to set your framing and constraints
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
}
Try this one. This should put the image on top of the nav bar.
override func viewDidAppear(_ animated: Bool) {
//Adding the button
navigationController?.navigationBar.addSubview(buttonView)
let navBar = navigationController?.navigationBar
// use this navBar to set your framing and constraints
let buttonImage = #imageLiteral(resourceName: "button")
var buttonView : UIImageView {
let view = UIImageView(image: buttonImage)
view.translatesAutoresizingMaskIntoConstraints = false
view.frame = CGRect(x: self.view.frame.maxX - 100, y: -100, width: 200, height: 200)
view.backgroundColor = .clear
return view
}
}
answered Nov 26 '18 at 6:34
aka ak aka ak
7729
7729
hey thanks for your comment! your code solved the issue of the image not showing over the navigation bar, but now the image is huge and I can't resize or change the coordinates of the image! I'm trying to manipulate it through CGRect....
– teachMeSenpai
Nov 26 '18 at 21:53
figured it out. Thanks mate
– teachMeSenpai
Nov 28 '18 at 18:24
add a comment |
hey thanks for your comment! your code solved the issue of the image not showing over the navigation bar, but now the image is huge and I can't resize or change the coordinates of the image! I'm trying to manipulate it through CGRect....
– teachMeSenpai
Nov 26 '18 at 21:53
figured it out. Thanks mate
– teachMeSenpai
Nov 28 '18 at 18:24
hey thanks for your comment! your code solved the issue of the image not showing over the navigation bar, but now the image is huge and I can't resize or change the coordinates of the image! I'm trying to manipulate it through CGRect....
– teachMeSenpai
Nov 26 '18 at 21:53
hey thanks for your comment! your code solved the issue of the image not showing over the navigation bar, but now the image is huge and I can't resize or change the coordinates of the image! I'm trying to manipulate it through CGRect....
– teachMeSenpai
Nov 26 '18 at 21:53
figured it out. Thanks mate
– teachMeSenpai
Nov 28 '18 at 18:24
figured it out. Thanks mate
– teachMeSenpai
Nov 28 '18 at 18:24
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%2f53473083%2fhow-to-place-uiimageview-over-the-navigationbar%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
is that a navigation bar or a tableViewHeader?
– Joshua
Nov 26 '18 at 0:05
it's a Navigation bar. I'm reading around and some say that it has to do with the scope of the view. If that's the case, how can I get it so that the top half of the circle fades in as a UIimage whenever the tableview is scrolled to the top? I'm assuming you'd have to have another copy of the image and just crop, but what would the animation look like and how would I detect the bar expanding? At the moment, the circle scrolls away with the table, which I actually think is cool, so as long as I can get the entire thing to show when I'm positioned the same as the image, that'd be fine with me.
– teachMeSenpai
Nov 26 '18 at 0:13