uibarbuttonitem

Enabling done button after inserting one char in a textfield: textFieldDidEndEditing: or textFieldShouldBeginEditing: or?

独自空忆成欢 提交于 2019-11-30 12:14:28
问题 I would like to enable the done button on the navbar (in a modal view) when the user writes at least a char in a uitextfield. I tried: textFieldDidEndEditing: enables the button when the previous uitextfield resigns first responder (so with the zero chars in the current uitextfield). textFieldShouldBeginEditing: is called when the textfield becomes the first responder. Is there another way to do this? [EDIT] The solution could be -(BOOL)textField:(UITextField *)textField

How to convert UIImage/CGImageRef's alpha channel to mask?

﹥>﹥吖頭↗ 提交于 2019-11-30 10:32:28
问题 How can I extract the alpha channel of a UIImage or CGImageRef and convert it into a mask that I can use with CGImageMaskCreate? For example: Essentially, given any image, I don't care about the colors inside the image. All I want is to create a grayscale image that represents the alpha channel. This image can then be used to mask other images. An example behavior of this is in the UIBarButtonItem when you supply it an icon image. According to the Apple docs it states: The images displayed on

Add custom button to navigation controller without border

纵然是瞬间 提交于 2019-11-30 09:01:04
I add custom button to navigation controller UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)]; self.navigationItem.leftBarButtonItem = backButton; it works fine, but button appears bordered. How can I fix that? UPDATE I found solution UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 25, 25)]; [button setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonFavoriteClicked)

Adding UIBarButton item in swift

ぐ巨炮叔叔 提交于 2019-11-30 08:39:04
I'm trying to add a UIBarButton item to my nav bar. Here is my Navigation Bar class declaration: import UIKit class NavigationBarController: UINavigationController { override func viewDidLoad() { super.viewDidLoad() configureToolbar() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } // #pragma mark - Navigation bar data source func configureToolbar() { let toolbarButtonItems = [ searchBarButtonItem ] toolbar.setItems(toolbarButtonItems, animated: true) } var searchBarButtonItem: UIBarButtonItem { return

UIBarButtonItem icon white when added via IB, black when added programmatically

南笙酒味 提交于 2019-11-30 07:24:54
When I add an icon to a UIBarButtonItem via the Interface Builder, the icon is displayed white. When I add the same icon file programmatically to another UIToolbar , the icon is displayed black. Why? UIImage *image = [UIImage imageNamed:@"icon.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:image forState:UIControlStateNormal]; rootViewController.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:reloadButton] autorelease]; Everything Jongsma said is right, you should use the initWithImage:style: message. The next problem

Customizing UIBarButtonItem “Done” style and “Plain” style separately using UIAppearance

浪子不回头ぞ 提交于 2019-11-30 06:54:21
I know how to customize UIBarButtonItem using -setBackgroundImage: forState: barMetrics: , but I would like to use different images for UIBarButtonItemStyleDone and UIBarButtonItemStylePlain . Is there a way to accomplish this using the UIAppearance protocol? Or do I have to set the image each time I want a "Done" style button? (I tried messing around with code like the following: [[UIBarButtonItem appearance] setBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarButtonItemStyleDone]; But that just sets every bar button with the "Done" image.) Thanks! Sergiy Salyuk In iOS 6

Changing the Tint Color of UIBarButtonItem

痞子三分冷 提交于 2019-11-30 06:49:32
问题 I have a project using Storyboards and whenever I push a view controller with a segue, the dynamically created bar button item is always blue. It's driving me nuts. Because this object is created dynamically, I cannot set its color in IB (like I have done with previous bar button items). Among the solutions I have tried are: Set it in the receiver's viewDidLoad Set it in the receiver's viewDidAppear self.navigationItem.backBarButtonItem.tintColor = [UIColor whiteColor]; When I saw that didn't

image for nav bar button item swift

我怕爱的太早我们不能终老 提交于 2019-11-30 06:45:05
I want to display an image in the left hand side of my nav bar in swift. I have tried adding a nav bar button item and setting an image there. The problem is that I have to use a really small image for it to fit in the nav bar nicely. But making such a small image leads to pixelation especially on the bigger phone iPhone 6 and 6 Plus. Is there a way to use a good quality image and then set the frame to fit within the bounds of the nav bar? My attempt: var image = UIImage(named: "Harp.png") image = image?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) self.navigationItem

UINavigationBar BarButtonItem with Plain Style

笑着哭i 提交于 2019-11-30 06:36:38
问题 i got the following code: - (id)init { if (self = [super init]) { self.title = @"please wait"; UIBarButtonItem *favorite = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"star.png"] style:UIBarButtonItemStylePlain target:self action:@selector(buttonFavoriteClicked:)]; self.navigationItem.rightBarButtonItem = favorite; } return self; } but my button looks still like a Button with UIBarButtonItemStyleBordered is there a way to set a button with plain style at this position? 回答1:

Custom background for UINavigationBar problems

半世苍凉 提交于 2019-11-30 05:32:21
I've managed to add a custom background to my navigation bar by using: UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"UINavigationBar.png"]]; [myViewController.navigationBar insertSubview:iv atIndex:0]; [iv release]; This works fine and I can see the title and buttons okay. However, when I drill down one level and then go back to the root, the buttons are hidden, but the title is still visible. It appears the navigation bar image is covering the button items. I'm confused as I'm inserting it at the bottom so I would assume when the navigation items are pushed and