I would like to know how to place a right navigation arrow button on the navigation bar, and display it with text, just like it is the Apple Music and Apple Podcast apps:
So, as Sen briefly described, you want to drag a UIView into your navigation bar in your UIViewController in Xcode's storyboard (it will automatically get wrapped into a Navigation Bar Item when you drag it in). Then, change the UIView's class to UIControl (this will allow you to put a tap gesture recognizer in it later, but it acts like a UIView for now).
Now add two things to the view (control): UILabel and UIImageView. Type whatever you want into the label and give it the desired size, etc. Now, for the UIImageView, you'll have to drag the arrow image (link below) into your project in Xcode. You can literally just download the image, drag it onto the project source code explorer panel in Xcode, make sure that the option for copying the image in if needed is checked, and then click "OK".
Now, click on your UIImageView in the storyboard and choose the image you just dragged into Xcode as the UIImageView's image (it's name should appear automatically in the drop down box if you dragged the image into Xcode correctly; and the image drop down box can be found on the right side panel in Xcode if you have the UIImageView selected in the storyboard). In order to make the arrow look like Apple's, set it's size to about 35 x 35.
Now, all you need to do is drag a Tap Gesture Recognizer onto your UIControl, and then control+drag from the tap gesture (which is in your storyboard document outline) into your view controller's source code. This will make a method in which you can add code to segue. For example:
- (IBAction)forwardButtonClicked:(id)sender {
[self.navigationController pushViewController:self.someViewController animated:YES];
}
Now it's all hooked up!
Hope this isn't too confusing. Let me know if you have any questions.
Here's the link to the image: https://www.iconfinder.com/icons/211688/arrow_forward_icon#size=512 (You can just download it as a .png with the button at the bottom of the web page).
In order to make it blue like Apple's back arrow, I did the following:
I opened the downloaded image in a photo editor (such as GIMP)
I took a screen shot of Apple's default back button arrow (use cmd+shift+4 to take a screen shot while the simulator is open).
I opened the screen shot in the photo editor.
I used the color selector tool and chose the color of Apple's arrow.
I used the paint bucket and filled in the color of my arrow image.
I exported my blue arrow image as a .png (and now you can just drag this .png into Xcode like I mentioned before).
Related
I'm developing iOS app with XCode.
My problem is a corner radius of UIViewController as below.
I want to remove it. It's shown on only iPhone7 simulator.
Please help me.
Get a reference to your UIView's layer and then call this function:
view.layer.cornerRadius = 0
It could be a couple of things:
Corner radius;
Background image that incorrectly had its corners rounded; or
Mask applied to the layer.
If you’re having trouble identifying the specific view that this has this applied, use the view debugger. So, run the app via Xcode and then tap on the view debugger button .
When your views appear in Xcode’s view debugger, rotate the view and select the culprit.
Once you’ve highlighted the view of interest, you can press shift+command+D, or choose “Navigate” » “Reveal in Debug Navigator” from the Xcode menu , and it will highlight the view in the view hierarchy shown on the left. Or if you choose the object inspector in the right panel, you can see the class name, and if it’s one of your classes, you can click on the little arrow to the right and you will be taken directly to your code.
Here's my setup: I have a ViewController that contains an image(button). This button takes the user to another viewController using an #IBAction func (tab controller tab). However, I also want a scrollView on the initial ViewController, just under the image button.
What I'm trying to achieve is the ability to scroll content on top of the image button as if it were another page on top of the image button. As the user scroll back down, the image button is revealed underneath the scrollView and is clickable again.
I can't seem to find a solution anywhere online. My scrollView is either fixed below the image button, or covers the image button rendering it unclickable.
Here's a screenshot
take a look at the demo project i set up:
https://github.com/slotti85/ButtonAndScrollView
i...
put the scrollview all over the screen (also over the button),
set up a contentInset to make the button visible initially,
subclassed UIScrollView and
overrode the pointInside function to make the scrollview forward a touch if the "transparent area" is tapped.
hope it helps!
I have a custom UI Button (just regular button but with image), within the navigation bar, but when I choose my image it looks like this in designer:
As you can see here, it's over my provider and status labels, and also when I run application it's over the WebView (which is bellow), so definitely out of navigation bar. I tried to find in storyboard some property where I can adjust this but I couldn't find any. I'm using swift and storyboards.
Appreciate any help, iOS newbie :)
Based on your description I think your issue is that you are trying to add a button for navigation. What you need is a NavigationBar with a NavigationItem/BarButtonItem in it. If you look in the object library you will be able to find these.
Just drag them onto your story board. Once there select the button and in the side menu you will be able to select the Image for that Item. Now it is in the navigation bar up top. Let me know if there are still issues. 👱🏼
You have to make sure your 1x image is to the specified size (and then your 2x etc, or just use a PDF at the 1x size.
Icon sizes are here: iOS Human Interface Guidelines: Icon and Image Sizes
I made my pdf 22x22 and added it to .xcassets with scale factor "single vector"
I'm working with an xcode storyboard. I was resizing a label and it pushed a UIImage outside of the frame, so I can no longer see it. I can't grab it. How do I move it back on the frame so I can see it?
I can verify that it is in my tableview cell, because it is still listed under the content view on the left bar.
Thanks
You can also select the element from you view controller scene from the document outline (on the left) and move it around with your keyboard arrow keys (double click so it's grey and not blue, if it's blue you will navigate the scene). I use the arrow keys most often to position my elements relative to each other. Holding the option key while moving the mouse to different elements gives alignment and distance guidelines to other objects while you move with the arrow keys.
On the left side of the storyboard, expand the elements for your UITableViewCell. You should see the UImage listed. Click on it, then go into the right menu and change the x,y coordinates. It'll now put it back to where you can see it and edit it.
Also just be careful about having your UIImage object as the bottom layer. I've hidden things from myself when they were accidentally put as the bottom layer.
There is a better way for Xcode 10 and above:
Navigate to the storyboard
Choose the controller of the controller scene you want to see the element of
Under size inspector, select 'Freeform' from the Simulated size dropdown
Increase the width/height and hit return.
After you have laid out all elements in the canvas and no longer want to see elements which are outside of frame, revert back to 'Fixed' simulated size under Size inspector.
I am using SWRevealViewController as a slide menu in iOS. When I created the rear viewcontroller (the slide menu) a xib file was created with .m and .h files. I do not use autolayout and set the simulated metrics size as None.
The view seems all right when slide in and out on iPhone except that when the view is presented on iPad I want the positions of the menus to also change as the view becomes bigger but it doesn't.
Originally the view is as the image below shows:
In order to move the "settings" menu to the bottom I have made changes to the view settings of "settings image", "settings button" and the extra UIImageView as below:
but I want the settings menu to also locate at the bottom of the view just like it is now on iPhone. How can I do that?
I have used "Masonry" library to sort this out.
It is pretty amazing.
Check out Masonry from GitHub