uibarbuttonitem

Changing back button background image

拈花ヽ惹草 提交于 2019-12-08 00:42:33
问题 Using this method to change title and background image of the back navigation button. Title is changed but button stays black - (void)viewDidLoad { [super viewDidLoad]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"topBarbackground.png"] forBarMetrics:UIBarMetricsDefault]; UIBarButtonItem *backButton = [UIBarButtonItem new]; [backButton setBackgroundImage:[UIImage imageNamed:@"backButton.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

UIToolbar Resizing causes weird UIBarButtonItem size in Landscape

丶灬走出姿态 提交于 2019-12-07 19:55:57
问题 When I create and add a UIToolBar and UIBarButton items, how can I get the toolbar and items to appear properly in both orientations. This is what I have so far: self.toolbar = [[[UIToolbar alloc]initWithFrame:CGRectMake(0, 372, 320, 44)]autorelease]; self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.deleteButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target

UITabbar in Xcode 6

牧云@^-^@ 提交于 2019-12-07 19:30:24
问题 I have UITabbarController with 4 tabs in iPhone 4, 4s, 5, 5S it is woking fine with tabbar item image But in iPhone 6 and iPhone 6 plus is looking wired. Is it need to put different images for both iPhone 6 and iPhone 6 plus ? How can I set this images. in iphone 6 And, iPhone 6 Plus 回答1: I ran into this same issue. The problem here is not only the different resolution, but the fact that the size of the bounds is actually wider for iphone 6 and iphone 6 plus. By running the simulator on all

UIBarButton with CustomView and a Border

和自甴很熟 提交于 2019-12-07 18:52:17
问题 I've subclassed UIBarButtonItem and am trying to make a button which dispays a refresh image normally, but an activity spinner when loading. The problem I have is I can't get the bordered style to display a custom view inside. It just doesn't appear. This is my code (from my UIBarButtonItem subclass's constructor): self = [super initWithTitle:@"" style:UIBarButtonItemStyleBordered target:self action:nil]; UIView *viwInner = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 24,24)]; [self

UIBarButtonItem-Badge for iOS

主宰稳场 提交于 2019-12-07 17:38:48
问题 I am using this control for showing badge on barbuttonitem. It works fine for the first controller or root controller in navigation controller stack. While pushing to another controller, I tried to show badge and I cannot see any effect there. 回答1: You should first time set badgeValue in viewDidLayoutSubviews . In this case it'll appear and don't blink, like if you set it in viewDidAppear : - (void)viewDidLayoutSubviews { barButton.badgeValue = @"5"; } 回答2: Setting navigationItem in

How do I prevent UIPopoverController passthroughViews from being reset after orientation change when presented from a UIBarButtonItem?

試著忘記壹切 提交于 2019-12-07 15:36:13
问题 I have a UIPopoverController which is being presented from a UIBarButtonItem. I want touches outside of the popover to dismiss the popover. When presenting a popover from a bar button, the other bar buttons are automatically included in the popovers passthrough views. In order to prevent that I set the passthrough views to nil (or @[ ]) after presenting the popover, like so: - (IBAction) consoleBarButtonHit:(id)sender { UIViewController *consoleNavigationController=[self.storyboard

iphone - How can I use an UIBarButtonItem style without the UIToolBar

*爱你&永不变心* 提交于 2019-12-07 14:26:13
问题 Can I show a black style UIBarButtonItem in my view without the underneath UIToolBar? The UIToolBar always has a kind of border thing, I want the system UIBarButtonItem in black just like a black standard cancel button, but not the UIToolBar How can I do it? Thanks 回答1: there is a cheeky hack that will help you with this. you want to use a UISegmentedControl with style set to UISegmentedControlStyleBar and only one item. You also need to setMomentary to yes - to make it behave like a button:

Can set background image for UIBarButtonItem in nav bar, but not bottom toolbar

房东的猫 提交于 2019-12-07 08:19:26
So this works when adding the item to the nav bar, but when i add it to the toolbar set in the bottom bar via interface builder, the background image doesn't show up. UIBarButtonItem *resetButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Reset" style:UIBarButtonItemStylePlain target:self action:@selector(resetCriteria:)]; UIImage *img = [UIImage imageNamed:@"someImage.png"]; img = [img stretchableImageWithLeftCapWidth:5 topCapHeight:20]; [resetButtonItem setBackgroundImage:img forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; self.toolbarItems = [NSArray arrayWithObjects:

Explain this margin logic for leftBarButtonItem, rightBarButtonItem, titleView

你说的曾经没有我的故事 提交于 2019-12-07 06:05:39
问题 Can anyone explain to me where the margins you see in this screen shot below are coming from? I want the red, green and blue rectangles to all fit next to each other in both screen layouts, landscape and portrait. Instead I see inexplicable margins between the views. // Setup Left Bar Button item UIBlankToolbar* tools = [[[UIBlankToolbar alloc] initWithFrame:CGRectMake(0, 0, 115, 44)] autorelease]; tools.autoresizingMask = UIViewAutoresizingFlexibleWidth; [tools setBackgroundColor:[UIColor

iOS lazy var UIBarButtonItem target issue

笑着哭i 提交于 2019-12-07 04:26:36
问题 I found this UIBarButtonItem target issue unconsciously when using lazy var initialization. class ViewController: UIViewController { lazy var barButtonItem1 = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(action1)) lazy var barButtonItem2: UIBarButtonItem = { let barButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(action2)) return barButtonItem } override func viewDidLoad() { super.viewDidLoad() print(barButtonItem1