uitoolbar

Custom UIBarButtonItems from UIButtons with custom images - is it possible to make the tap targets larger?

限于喜欢 提交于 2019-11-27 14:45:10
问题 I'm making UIBarButtons as follows: // Create "back" UIBarButtonItem UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; backButton.frame = CGRectMake(0, 0, 28, 17); [backButton addTarget:self action:@selector(backButtonTapped) forControlEvents:UIControlEventTouchUpInside]; backButton.showsTouchWhenHighlighted = YES; UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"]; [backButton setBackgroundImage:backButtonImage forState:UIControlStateNormal];

iOS Autolayout and UIToolbar/UIBarButtonItems

让人想犯罪 __ 提交于 2019-11-27 14:19:21
I have an iOS view with autolayout enabled and have a UIToolbar with a UISearchBar and UISegmentControl contained with the toolbar. I want the UISearchBar to have a flexible width so I need to add a constraint to force this, but from what I can tell you cannot add constraints to items in a UIToolbar in Interface Builder. The options are all disabled. Before AutoLayout I would accomplish this with autoresizingmasks . Are constraints not allowed within UIToolbars/UINavigationBars ? How else can this be accomplished when using autolayout? snorock Autolayout constraints only work with UIViews and

Set rootViewController of UINavigationController by method other than initWithRootViewController

醉酒当歌 提交于 2019-11-27 11:38:01
How Do I set the rootViewController of UINavigationController by a method other than initWithRootViewController ? I want use initWithNavigationBarClass:toolbarClass: to deliver a custom toolbar for my NavigationController, so I don't think I can use initWithRootViewController . You can solve this by calling setViewControllers . Like this: UINavigationController *navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[MyNavigationBar class] toolbarClass:[UIToolbar class]]; [navigationController setViewControllers:@[yourRootViewController] animated:NO]; Knowledge

Can I give a UIToolBar a custom background in my iPhone app?

前提是你 提交于 2019-11-27 10:53:20
Is it possible to give a UIToolBar a custom background from an image rather than the usual tinted blue/black fade out? I've tried giving the view a background and setting the opacity of the UIToolBar but that also affects the opacity of any UIBarButtons on it. Answering my own question here!!! Overriding the drawRect function and creating an implementation of the UIToolbar does the trick :) @implementation UIToolbar (CustomImage) - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed: @"nm010400.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size

How to add a UIToolbar to a UITableViewController programmatically?

主宰稳场 提交于 2019-11-27 10:47:47
问题 I have opted to use a UITableViewController without a nib. I need a UIToolbar at the bottom with two buttons. What is the simplest way of doing that? P.S. I know that I can easily use a UIViewController and add a UITableView however I want things to look consistent across the app. Can someone help? I saw the following example and I am not sure on its validity: (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; //Initialize the toolbar toolbar = [[UIToolbar alloc] init];

Aligning UIToolBar items

独自空忆成欢 提交于 2019-11-27 06:09:29
I have three UIBarButtonItem created as below. They align left and I'd like to align center so there isn't a gap on the right side. I don't see an align property on UIToolBar . Is there another way to accomplish this? //create some buttons UIBarButtonItem *aboutButton = [[UIBarButtonItem alloc] initWithTitle:@"About" style:UIBarButtonItemStyleBordered target:self action:@selector(showAbout:)]; [toolbar setItems:[NSArray arrayWithObjects:settingsButton,deleteButton,aboutButton,nil]]; //Add the toolbar as a subview to the navigation controller. [self.navigationController.view addSubview:toolbar]

UIBarButtonItem with UIImage Always Tinted iOS 7

余生颓废 提交于 2019-11-27 05:09:50
问题 I'm trying to add a UIBarButtonItem containing a UIImage to a UIToolbar . The image keeps being tinted and I can't get it to show as the original colored image - all I want to do is display an image, verbatim, in a UIBarButtonItem ! I'm following the directions in the iOS 7 transition guide to set the image rendering mode to UIImageRenderingModeAlwaysOriginal . UIImage *image = [UIImage imageNamed:@"myImage.png"]; image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

Show/hide UIToolbar, “match finger movement”, precisely as in for example iOS7 Safari

允我心安 提交于 2019-11-27 04:26:19
Note: check out Thuy's great subclass of UINavBar here: https://stackoverflow.com/a/20720359/294884 If you're working on this problem, GTScrollNavigationBar is close to a ready-made solution to the navBar problem! 50 point bounty here, amazing there are no answers. For example: on a 2014 iPhone, open Safari, load any web page. Look at the iOS toolbar at the bottom. Now move your finger up and down ONLY A FEW PIXELS . Basically the toolbar at the bottom, moves with your finger . Furthermore, the toolbar later appears/disappears as you scroll the page , following specific logic. But the

UIToolbar UIBarButtonItem with both image and title has very dim text

点点圈 提交于 2019-11-27 03:38:49
问题 My iPhone view adds some custom buttons to its toolbar. Each button has both an image and textual title, and is created like this: UIBarButtonItem *fooButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"foo.png"] style:UIBarButtonItemStylePlain target:self action:@selector(fooButtonPressed:)]; fooButton.title=@"Foo"; The title's text displays very dim; it looks like it has an alpha of about 0.5. If I use the default UIToolBar barStyle, I can't read the text at all. When

iOS - using UISearchDisplayController with UISearchBar that is UIBarButtonItem in UIToolbar

大城市里の小女人 提交于 2019-11-27 03:31:54
问题 Has anyone tried using a UISearchDisplayController with a UISearchBar that is a UIBarButtonItem in a UIToolbar? I would appreciate tips on how to do this successfully. Currently whenever the search controller pops up it redraws the UISearchBar and I'm struggling to maintain a similar look to the UIToolbar 回答1: Usually you don't want to put a search bar inside a toolbar, however, it seems you want to do something similar to what I did. So here is how I did it, it may be called a hack, but it