I'm trying to customize my UIImagePickerController's status bar appearance. I have a custom image I'm using for the back button, which properly appears, but what I'd like to do is remove the text (so it's just the image). I regularly do this throughout my app, but I can't seem to get it working in the UIImagePickerController.
I figured I could do something like...
UIImagePickerController *uiipc = [[UIImagePickerController alloc]init];
uiipc.navigationController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"" style:UIBarButtonItemStylePlain target:nil action:nil];
However that does not seem to work, when selecting a folder e.g. "Photos" I still get the custom image with the text "Photos" next to it for the back button.
Could someone give me a hand removing the text?
EDIT: Worth noting that the custom image is set in my app delegate, which is why you don't see that in my example.
You could use appearance proxy method:
UIOffset backButtonTextOffset = UIOffsetMake(0, -60);
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:backButtonTextOffset
forBarMetrics:UIBarMetricsDefault];
this will take out title text way. See the attached image for iOS 7.
Related
I want to add back button on NavBar in iOS, but I can't find back array image on systemItem. Is there any property of default back arrow image.
I tried SMF.UI.iOS.BarButtonType.cancel but it has a title says "VazgeƧ" instad of back arrow image.
You must assign onSelected event of back item.
Can you try this;
var leftItem = new SMF.UI.iOS.BarButtonItem({
systemItem : SMF.UI.iOS.BarButtonType.cancel,
onSelected : Pages.back()
});
this.navigationItem.leftBarButtonItems = [leftItem];
You should use Navigation Controller for that. Then the back button will appear automatically.
If you want to display only image, without text, put this code in the view controller that you came from.
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:#"" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
UIBarButtonItem *adminBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:#"779-users"]
style:UIBarButtonItemStylePlain
target:self
action:#selector(adminButtonTouched)];
I tried to assign a new frame to adminBarButtonItem.customView.frame, it didn't work.
Expect for [[UIBarButtonItem alloc] initWithCustomView:aView], is there anyway to change the size of UIBarButtonItem?
I encountered a similar situation where I needed to resize a custom image to fit alongside another system bar button item. The key is to resize the image itself before I use it in UIBarButtonItem's initWithImage method.
For how to resize that UIImage, follow this link The simplest way to resize an UIImage?
Another pitfall is the tintColor of the custom button item. I used
myButtonItem.tintColor = [UIColor colorWithPatternImage:myImage];
to get around the blue tint that covers up my image (iOS8), but I suspect there exists a more kosher way. If anybody knows, please enlighten me.
I need to create a navBar back button in accordance to the designer's plan. The back button has a pattern image and stitched leather on the perimeter.
Here it is:
My question is it possible to create this without a great amount of hassle and headache? Or if it's possible at all, since the back button has varying width?
Thanks!
UPDATE
Alright, with the help of PartiallyFinite turns out this is very easy. If you set the UIEdgeInsets correctly it will keep the left side fixed, the right side fixed, and then duplicate the middle of the image considering the back button's width.
This is the image I used for my back Button:
And these are my inset settings. You can try them yourself:
backButtonImage = [backButtonImage resizableImageWithCapInsets:UIEdgeInsetsMake(5, 17, 5, 12)];
Hope this helps someone in the future.
You will need to provide a stretchable image for the button, so it knows how to display it correctly:
UIImage *buttonImage = [[UIImage imageNamed:#"backButtonImage"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 6)]
You don't need to do anything special to the image itself, but you do need to specify appropriate edge insets for the resizable image to indicate the area around the edges of the image that should not be stretched, as shown above (the example shows an inset of 15 pixels from the left and 6 from the right). This area should cover the arrow head, and the curved right edge, so that the middle area can be stretched out as needed. Read the documentation for more information on this method.
UPDATE: By default, the resizable area of the image will be tiled to the new size, however if you want to have it stretch instead, you can use resizableImageWithCapInsets:resizingMode: and pass UIImageResizingModeStretch to achieve that behaviour. For your case obviously tiling is better as it preserves the stitching, but for some background images stretching is a better solution. Just putting this here to help anyone who sees this in the future.
Once you have the stretchable image, you can change the appearance your back button using this code:
[myBackButtonItem setBackButtonBackgroundImage:buttonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Alternatively, you can set this custom appearance for all back buttons in your app using this code:
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run this when your app launches, and it will affect all back buttons in your app.
Note that, contrary to what some of the other answers suggest, you will not need to manually create any back buttons. If you create a UINavigationController and use it in the recommended way (read about that in the documentation, a navigation bar and back button will be created for you as you push view controllers using pushViewController:animated:. If you use the global UIAppearance code snippet to apply the custom button style, it will automatically be applied to all the back buttons that you have.
You can read more about setBackButtonBackgroundImage:forState:barMetrics: in the official documentation.
There are also numerous tutorials available online for a more in-depth explanation of how this works and how to do it, here are a few good ones:
http://useyourloaf.com/blog/2012/08/24/using-appearance-proxy-to-style-apps.html
http://nshipster.com/uiappearance/
You need to create your own BarButtonItem. You can't set image for system back button.
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:buttonWithYourImage] autorelease];
You can create your own UIBarButtonItem and set it as the leftButtonItem on the navigation bar on the current view controller:
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"your_image"] style:UIBarButtonItemStyleBordered target:self action:#selector(yourFunction:)];
self.navigationItem.leftBarButtonItem = btn;
I use this in my Appdelegate.m to customize button. ("buttonBack" is the name of your image). Hope it may help you
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIImage *barButtonImage = [[UIImage imageNamed:#"buttonBack"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
[[UIBarButtonItem appearance] setBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
return YES;
}
First you need to make your own back button.. and set that image to back button.
UIBarButtonItem * btn=[[UIBarButtonItem alloc]initWithTitle:#"Back" style:UIBarButtonItemStyleBordered target:self action:#selector(changed)];
self.navigationItem.leftBarButtonItem=btn;
[btn setImage:[UIImage imageNamed:#"yourimagename"]];
-(void)changed
{
[self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:0] animated:YES];
}
try this one really helpful to you...
I would like to setup the navigation controller bar button item to be an image.
I have read the following - Add image to a navigationItem's title
I understand how to setup this as an image. I am actually looking to set this up as the setting cog, within the bar button item (like a cog icon). I have seen this before in other apps, I would like to know if there is a default style to initialise for this or normally if this is achieved by the image route as above.
If this is above, does anyone know where this (kind of) default image styled icon is available, or would I need to make one?
Have you tried using the initWithCustomView option of UIBarButtonItem? A sample code will look like the below line.
UIBarButtonItem *aButton = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"settings.png"]]];
Another way to do this is,
UIBarButtonItem *aButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"settings.png"] style:UIBarButtonItemStyleBordered target:self action:#selector(buttonTapped)];
If you use storyboard, you can directly:
Drag a Button in the navigation bar instead of a Bar Button Item. It will automatically create a Button Bar Item for you with a Button inside it.
Enter a title for the Button Bar Item
Set an image for the Button with a Custom type.
It should works.
I am new to iOS app dev. I want to create UI similar to bottom tools line in iPhoto app.
Any tutorial or tips will be really helpful.
Click this link to see UI of iPhoto app.
First image from above link shows the bottom tool container.
Thanks.
you can use a normal UIToolbar.
Here is a tutorial for adding UISlider to your toolbar: http://eureka.ykyuen.info/2010/06/09/iphone-adding-uislider-to-uitoolbar/
// Initialize
aSlider = [[UISlider alloc] init];
UIBarButtonItem *sliderAsToolbarItem = [[UIBarButtonItem alloc]
initWithCustomView:aSlider];
// Set the width of aSlider
[sliderAsToolbarItem setWidth:250.0];
// Add the items to the toolbar
[toolbar setItems:[NSArray arrayWithObjects:sliderAsToolbarItem, nil]];
If you search for custom UIToolbar you are getting tons of results with tutorials.
Here you can find a custom UITabbar: http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/
Or you can just use a view with buttons in case of toolbar or tabbar and set it to bottom.