uibarbuttonitem

iOS 5: How to implement a custom (image) back button

北城以北 提交于 2019-12-20 09:47:09
问题 I've done the tutorial at my blog, so I know how to make a stretchable button that can display the bottom (stack) viewcontroller's title. But what I was hoping to do is have icons (like a house for HOME) and no text and not resize. Using my custom image and this code below, I get a stretched version (not wanted) with title over top (not wanted) and it does tint/highlight when clicked (is good); UIImage *backButtonImage = [UIImage imageNamed:@"backButton_30.png"]; [[UIBarButtonItem appearance]

Add UIToolBar to all keyboards (swift)

有些话、适合烂在心里 提交于 2019-12-20 09:00:05
问题 I'm trying to add a custom UIToolBar to all of my keyboards with as little repetition. The way I'm currently doing it requires me to add the code to all my viewDidLoads and assign every textfield's delegate to the viewController I'm using. I have tried creating my own UIToolBar subclass but I find that I can't really do that when the target for my "Done" and "cancel" buttons are the self view. Does anyone have any suggestions for creating an easily reusable toolbar? Thanks in advance.

navigation bar right bar button items spacing

只愿长相守 提交于 2019-12-20 08:58:08
问题 I have created a with left bar button item added from storyboard, titleView and three right bar button items from code. Here is the code: override func viewDidLoad() { super.viewDidLoad() var screenWidth = UIScreen.mainScreen().bounds.width // custom title view var navBarWidth: CGFloat = self.navigationController!.navigationBar.frame.size.width let customTitleView = UIView(frame: CGRectMake(0, 0, navBarWidth, 44)) titleLabel = UILabel(frame: CGRectMake(20, 0, navBarWidth, 40)) titleLabel.text

Custom UINavigationBar with custom height causes the UIBarButtonItem's to be positioned wrong

China☆狼群 提交于 2019-12-20 08:49:48
问题 I created my own subclass of UINavigationBar in order to enable custom background that is taller than 44pxs. I did it by overriding these two methods: -(void) drawRect:(CGRect)rect { [self.backgroundImage drawInRect:CGRectMake(0, 0, self.backgroundImage.size.width, self.backgroundImage.size.height)]; } - (CGSize)sizeThatFits:(CGSize)size { CGRect frame = [UIScreen mainScreen].applicationFrame; CGSize newSize = CGSizeMake(frame.size.width , self.backgroundImage.size.height); return newSize; }

Setting a UIImage to a UIBarButton item

不羁岁月 提交于 2019-12-20 06:26:18
问题 I can't seem to add an image to this UIBarButtonItem without it crashing when touched: UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil]; self.navigationItem.backBarButtonItem = backButton; [backButton release]; this code adds an image, but it crashes when touched because of an incompatible pointer types assigning to UIBarButtonItem * from UIButton: //Setup Custom Button UIButton *button = [[UIButton alloc] init

Displaying notification badge like counter in UINavigationbar

拈花ヽ惹草 提交于 2019-12-20 04:38:46
问题 I have a requirement to display number of pending notifications in iPhone navigation bar. The appearance should be like that of notification badge - but these are not APNS notifications. They are the ones sent from private server with similar purpose. I tried adding a right/left button ( UIBarButtonItem ) in my UINavigationbar but it seems like it is very rigid in appearance. I can't set its width, fonts etc. See my code: self.notifButton = [[UIBarButtonItem alloc] initWithTitle:@"0" style:

UIBarbuttonItem change the textColor

纵饮孤独 提交于 2019-12-20 04:24:12
问题 I have these two buttons in a toolBar and wants to change the color of UIBarButtons how can i do such a thing? i've tried setTitleTextAttributes, but it does not seem like it has a object with that? How can i do this UIBarButtonItem *sysDoneButton = [self createButtonWithType:UIBarButtonSystemItemDone target:self action:@selector(actionPickerDone:)]; UIBarButtonItem *sysCancelButton = [self createButtonWithType:UIBarButtonSystemItemCancel target:self action:@selector(actionPickerCancel:)];

UIBarButtonItem setTintColor doesn't work on iOS7

我们两清 提交于 2019-12-20 01:41:39
问题 In iOS6, I used this code to make my UIBarButtonItem: UIBarButtonItem* validate = [[UIBarButtonItem alloc]initWithTitle:@"MyTitle" style:UIBarButtonItemStylePlain target:self action:@selector(actionValidate)]; [validate setTintColor:[UIColor orangeColor]]; self.navigationItem.rightBarButtonItem = validate; It works fine in iOS6 but in iOS7, the color of the button changes only when you push it.. How can I fix this? 回答1: In iOS7 you if you need to change the navigationBar buttons color, you

Why am I getting an UIBarButtonItem customization warning?

时光怂恿深爱的人放手 提交于 2019-12-19 17:43:59
问题 I have a simple storyboard with a table view inside a navigation view controller that pushes from the table view to another view controller that has a full screen image view. The table view has a prompt text in it's navigation bar. When I tap on the table view cell in the table view I receive the warning below. I'm not customizing the back button at all. I created a sample project showing the issue. https://github.com/stevemoser/UIBarButtonItemCustomizationWarningExampleProject Anyone have an

How to show back button on the RootViewController of the UINavigationController?

梦想的初衷 提交于 2019-12-19 12:51:45
问题 Here is my code. I want to put a back button on the opening rootviewController. - (void)selectSurah:(id)sender { SurahTableViewController * surahTableViewController = [[SurahTableViewController alloc] initWithNibName:@"SurahTableViewController" bundle:nil]; surahTableViewController.navigationItem.title=@"Surah"; surahTableViewController.navigationItem.backBarButtonItem.title=@"Back"; UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController