create ios7 button on prior versions - ios

Is it possible to create button to be like one in ios 7 on prior versions of ios? I want my button just to show text, and not to be white rectangle or blue when selected.

try this ...
UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:#"text" forState:UIControlStateNormal]

If you are using Interface builder then just drag a button in to the view and in the Attributes inspector select type as custom and just add the required text in the placeholder.
Else if you are creating buttons programatically then
UIButton *buttonName = [UIButton buttonWithType:UIButtonTypeCustom];
[buttonName setTitle:#"Some Text" forState:UIControlStateNormal];

Related

UIButton is faded when pushed

I've set my UIButton normal state to one image and it's highlighted state to another. The button normal is fine but when I push the button down it sets it to a gray faded version of the image it's supposed to be. In the image below the top grayed out button is being pressed and the other buttons are in their normal state.The buttons are programmatically made.
UIButton *button;
UIImage *bluenormalImage = [UIImage imageNamed:#"bluebuttonnormal.png"];
UIImage *bluepressedImage = [UIImage imageNamed:#"bluebuttonpushed.png"];
[button setBackgroundImage:bluenormalImage forState:UIControlStateNormal];
[button setBackgroundImage:bluepressedImage forState:UIControlStateHighlighted];
OK, I didn't realise the text wasn't part of the image. Do this instead:
From what I can see you need to properly initialise the button as a custom type. The highlight issue occurs when the button type is system.
Change your button variable line to the following:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
If you initialise it later, you can do the following before you set the background image.
UIButton *button
button = [UIButton buttonWithType:UIButtonTypeCustom];

iOS 7 create a bottom UIToolbar like Photo and AppStore

I would like to create a bottom UIToolbar on iPad like Photo and AppStore apps. A taller toolbar whit custom UIBarButtonItem with image above text.
The problem is that I can't resize the 44px height in the .xib and if I try to change frame programmatically doesn't work.
Ideas ?
Edit
I want replace this interface with UIToolbar because the tab bar behavior is not what I need : I don't have many view controllers, but only functionalities that I want call from UIBarButtonItem.
Create a Image with your logo and text in it, assign it to a custom UIButton and assign it to UIBarButtomItem using initWithCustomView
UIImage *customImage = [UIImage imageNamed:#"yourCustomImage"];
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, customImage.size.width, customImage.size.height);
[backButton setImage:[UIImage imageNamed:#"yourCustomImage"] forState:UIControlStateNormal];
[backButton addTarget:self action:#selector(showPreviousView) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customBarButton = [[UIBarButtonItem alloc]initWithCustomView:customButton];
Hope this helps You..

Changing the Second Button Image by Clicking the First Button IOS7

Hi I'm trying to change the button image by clicking the another button for example i have two buttons like button1 and button2 already this two button has images but now I'm trying to change the second button image by clicking the first button in second button the new image should replace the old image please tell me how to do it.
- (IBAction)bt1:(id)sender {
UIButton *btn = (UIButton*)sender;
[btn setBackgroundImage:[UIImage imageNamed:#"vv.png"] forState:UIControlStateNormal];
}
- (IBAction)bt2:(id)sender {
}
**[btn setBackgroundImage:[UIImage imageNamed:#"vv.png"]** forState:UIControlStateNormal];
This above code is used to change the button image but i want know how to change the second button image by clicking image.
Thanks
You might have the IBAction property of a second button, which you can access in your implementation (.m) file with self (e.g. self.secondButtonPropertyName), now you can write the code like below:
-(IBAction)bt1:(id)sender
{
[self.btn2 setBackgroundImage:[UIImage imageNamed:#"vv.png"] forState:UIControlStateNormal];
}
first you set your both button tag..like btn1 tag =1 and btn2 tag =2
- (IBAction)bt1:(id)sender {
UIButton *btn = (UIButton*)[self.view viewWithTag:2];
[btn setBackgroundImage:[UIImage imageNamed:#"vv.png"] forState:UIControlStateNormal];
}
- (IBAction)bt2:(id)sender {
}
suppose you have two buttons btn1 and btn2
Now after them allocatng memory,
you can use below Button selector,
btn1 selector,
-(IBAction)btn1selector:(id)sender
{
[btn2 setbackgroundimage: [uiimage imagenamed:#"your image"]];
}
you can do same for the other button selector.

Set image of uiButton in custom table cell

I have a uitbutton within a custom table cell. I am trying to set the buttons image with
[cell.thumbImage setImage:[UIImage imageNamed: #"full_breakfast.jpg"] forState:UIControlStateNormal];
It is displaying a blue button instead of the image like so:
Am I doing this wrong? When i remove the uibutton setImage it returns to the normal button. This SHOULD be fairly simple so sorry if it is.
In iOS7 there is new button type called UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), // standard system button
Check your .xib file and change button type to Custom, or programatically you can do this:
[UIButton buttonWithType:UIButtonTypeSystem];

how to add the buttons to the popover view in ipad app

i want to add some text fields and the buttons to the popover view ...
how to add those and i hav to read the text added into text field by user later ...
....should i need seperate view controller class to control popover view or can i control with existed one which calls popover view....
any help Appreciated..
Create a UIViewController using IB or programatically. Add needed buttons, textfields and maybe some logic there and use this viewController for initializing an UIPopoverController (as Gendolkari suggested).
The UIPopoverView is created by passing in a ViewController which controls the content of your popover. Check out the initWithContentViewController:, this allows you to pass your own ViewController. That ViewController would have a view with the text fields and button that you want.
Try using this:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:#selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:#"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.tableView addSubview:button];

Resources