How can an iOS7-style "Now Playing" button be added to an UINavigationBar? - ios7

I'd like to add an iOS7 Music app style "Now Playing" button to the UINavigationBar
The button should have:
two lines of text
a right pointing chevron
How can this be achieved?

You will probably need the image for the chevron. If that's okay for you then you can create a UIButton with proper title and image insets and pass to initWithCustomView: method.
Note: you will also need to set numberOfLines = 2 for this button which as far as I know you can not do in IB

Related

How to display both text title and loading icon on the middle navigation?

If user clicks the icon, refresh starts. I found this https://github.com/Just-/UINavigationItem-Loading library, but it can't display both text title and loading icon on the middle navigation.
Like this photo:
Navigation item has property named "titleView".
Crete your view as you wish with label and reloadButton and then assign titleView this view:
self.navigationItem.titleView = [self getCustomView];
UINavigationBar is kind of UIView, You can do addSubView: in that. So add UILabel & UIActivityIndicator.
Let me know if you need anymore clarification.
Refer this link for code

I build keyboard with icon or image in Button and I want to show it in TextFiled or TextView

My keyboard built in a UIView with a button inside and I want when I press the button
the icon or image to show in a UITextField or UITextView.
Is this possible ?
Alloc image-view add image to the view and set the image-view to the text field property leftView/rightView
Example :
<textField>.leftView = <view>;

Resized UIToolbar refuses to keep its UIBarButtonItem aligned correctly

I have a UIToolbar at the top of my view, and it needs to be resized in an animation. The toolbar contains:
A UIBarButtonItem using system item UIBarButtonSystemItemAdd (the '+' button)
A UIBarButtonItem using a custom view (the title)
A UIBarButtonItem using the style UIBarButtonItemStyleBordered (the 'Edit' button)
I am adding these buttons using a spacer between each, which keeps the title in the center:
[toolbar setItems: #[addButton, spacer, titleButton, spacer, editButton] animated:NO];
The toolbar resizes just fine, and the two buttons keep their locations pinned to the outside edges. However, the title button does not stay in the center of the toolbar. Instead, it seems to pin its right edge to the same location, creating a space on its left side. During the animation, this give the impression that it is sliding right.
To be clear, I do want the title bar to keep its same width - I do not want it to expand as the toolbar grows. But I need the title to stay in the center of the toolbar.
Since a UIBarButtonItemis not a UIView, I can't (?) use the autoresizingmask functionality.
How do I keep the title in the center of the toolbar?
Additional Info
This might be because the Add and Edit buttons have different widths - when I add only the title (with a spacer either side), the behavior is correct.
It turns out that I was leaving out a crucial detail. I am manually setting the width of the edit button to 50.
If this is removed, the resizing works as expected. However, I am then unable to control the size of the Edit button, which I like to set to 50 so it matches the one on the navigation bar.
I found a workable solution. Keep the width of the Edit button at 50. Add a fixed separator immediately after the '+' button, and set its width to 18 (50 - the width of the '+' button). This balances the items either side of the title.
I know it's too bad, still you can use custom button as bar button item and use images of Add/Edit button in it. So that you can set the button frames, at any places. So your button won't placed to right most place.
UIButton * addButton = [[UIButton alloc] init];
[addButton setBackgroundImage:<AddimageName> forState:UIControlStateNormal];
UIBarButtonItem * addItem = [[UIBarButtonItem alloc] initWithCustomView:addButton];

Rotating UITabBarController Icon

I have an UITabBar in my application. One of the tab bar icons looks like a loading symbol. When the user presses the loading button I want the icon to spin/rotate until the loading is done. Should I use UIImageView to animate or something else? How should I make this happen?
Jacos, unfortunately you cannot do that with the UITabBarController and manipulate the tabBarController's tabBar properties. My best bet would be that you use a UIToolBar and assign a black color and make it appear like a tabBar and have buttons added in them as a subView so that they look like tabBarItems.
Its much more customizable, and you can even provide a scrolling experience and add more buttons to it.
I know this question is 4 years old but I had the same problem and managed to fix it by reading the tutorial in here:
https://medium.com/#werry_paxman/bring-your-uitabbar-to-life-animating-uitabbaritem-images-with-swift-and-coregraphics-d3be75eb8d4d#.bjfpbdnut
The main point is to get the view for desired UITabBarItem and the get the UIImageView from it in viewDidLoad:
UIView *plusView = self.tabBar.subviews[1];
self.plusImageView = plusView.subviews.firstObject;
self.plusImageView.contentMode = UIViewContentModeCenter;
Then in didSelectItem method you can do this:
[UIView animateWithDuration:0.4 animations:^{
[self.plusImageView setTransform:CGAffineTransformMakeRotation(M_PI/4)];
}];
My code only rotate the image view for 45 degrees but you can change as you wish.
I guess you could change the UITabBarItem's icon on a timer, but that seems pretty kludgey. You would have to pre-render each frame of your "loading" icon rather than rotate an ImageView.
Another hackey solution would be to add your ImageView to the UIWindow and move it on top of the TabBarController's TabBar (adding it to the TabBar itself is asking for trouble).
You shouldn't try to animate the actual UIImageView within the UITabBarController. I would take this approach:
Set the image for the relevant tab to nil or a blank image.
Create a UIActivityIndicatorView and add it over the tab bar. Position it over the correct tab.
[self.tabBarController.tabBar addSubview:activityIndicatorView];
When your loading task has completed, restore the normal image to the tab and remove the activityIndicator from the tab bar.

Objective C - UIImagePickerController customize bottom navigation

How can I customize the button and background color of UIImagePickerController's bottom navigation?
In the image below, it would be the "cancel" & "choose" button and the background.
Thank you,
Tee
I doubt you can do any customizations to default controls. You can have complete customized view (preview view) if you set showsCameraControls to NO.