I want to make a button which while expand after clicking, and expand to contain my table-view in it. Like quick graph application
In this application it expands with animation
Either you have to create the button using a core graphics OR simply use two images for the button states.
What you can do is on the UIButton click reveal the UITableView in animation. Plus change the UIButton image to the down arrow image. This can be done simply. Also according to the image you have shown, do you really need a tableview ? I think you can make a UIView and put a UILabel in it also. Just think about it . Any further queries or code help needed kindly reply :)
For adding the border use
Table.layer.borderWidth = 10;
Table.layer.borderColor = [[UIColor grayColor]CGColor];
Button.layer.borderWidth = 10;
Button.layer.borderColor = [[UIColor grayColor]CGColor];
Related
I would like to make a generic class that when tapped, makes the element grayish.
Facebook's app is the perfect example of what I want to achieve. All their links and images become gray when tapped.
I can only guess that they are subclassing UIButton.
I have made my button's style UIButtonTypeCustom to get rid of the rounded border. Beyond this, I don't know how to have the gray overlay because I see no such property in the documentation.
Its simple:
#define TAG_GRAYVIEW 5671263 // some random number
// add the gray overlay
UIView *grayView = [[UIView alloc] initWithFrame:button.bounds];
grayView.backgroundColor = [UIColor grayColor];
grayView.tag = TAG_GRAYVIEW;
[button addSubview:grayView];
// remove the gray overlay
UIView *grayView = [button viewWithTag:TAG_GRAYVIEW];
[grayView removeFromSuperview];
I think you need to use a semi transperant grey image PNG file. You need to then set Image of button in Highlighted state.
Also note that both the images for Normal State and Highlighted State need to have the images with titles on them.
As once we set the image to button, btn.titleLabel.text won't be displayed.
So you can have a image with transperant background and title on it for Normal state. And an grey image with title on it for Highlighted State.
Code for doing it programmatically is
[btn setImage:#"Transperant.png" forState:UIControlStateNormal];
[btn setImage:#"Grey.png" forState:UIControlStateHighlighted];
Hope this helps you.
The default UIButton masks the opaque content using a gray highlight. For example when using a transparent png, only the parts that contain non-transparent pixels will be grayed out on touch. The default UIButton highlight has no effect on subviews/sublayers, and will only work on provided images. What you see in the Facebook app is probably just a UIWebView highlight, possibly customized using css.
To create something similar using your own control (to prevent the overhead of a UIWebView) you should probably create your own UIControl subclass and highlight the content on touch using a transparent CALayer. You can even mask the CALayer to only highlight the actual contents, instead of a rectangular shape.
Also see my stackoverflow post on creating custom controls for iOS by subclassing UIControl.
Try setting the button up something like this.
*mind you I didn't create the image for this example.
Set your button type to custom, and in "State Config" select "Highlighted" from there you will want to set the image of the button to be a semi-transparent grey image. There are probably several other ways to achieve this same effect but this one should be nice and simple.
I'm using FlowCover in an app and need to add a background, but inserting a UIImageView and sending to the back in .xib only gives me the background image and buttons and no coverflow animation. I also cannot see where i would programme a
self.backgroundColor = [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:#"bground.png"]];
type thing in the implemetation.
Any clues?
It does appear that you can add an UIImageview to the ViewController's View in the MainWindow.nib:
In the editor dropdown you can send the image to the back. It means that the Flow Cover View MUST NOT be set to Opaque and then will sit on top of the ImageView.
how to Change UIbutton background color??
I try it on IB, but it doesn't work. only changes it for custom button.
I would like to change the white color on the rounded rect button.
Or instead how to make a custom button whit rounded corners
thanks!
Rounded rect button's color can be changed to any color with the background color property in IB as well as through coding, but can not change its color to transparent color easily. For that, you better use a custom button with either rounded image or set layer as demonstrated in the example and don't forget to add Quartz Core framework in you project as well as to import it in your class.
UIBUtton *myBtn = [UIButton buttonWithType:UIbuttonTypeCustom];
myBtn.frame = frame; //your desired size
myBtn.clipsToBounds = YES;
myBtn.layer.cornerRadius = 5.0f;
[self.view addSubView:myBtn];
You may find it difficult to adjust the default button. However you can use any view you want with a custom button.
Here's an article on creating views with rounded corners:
http://iphonedevelopment.blogspot.com/2008/11/creating-transparent-uiviews-rounded.html
You also may look at a program called Opacity, which allows you to create a a lot of customized standard iOS interface art/buttons.
http://likethought.com/opacity/
UIButton *tagButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
and have a look at this... that my do the trick.. i did it for mine.
You can use a custom UIButton with custom images for backgroundimage for each state. Just make the different states of your rounded button in photoshop for example.
You can use Custom button But for that use the image of button of white rounded corners
so it will be look like white round rectangle button
You should use UIButtonTypeCustom, instead of any other.
I have an app that I a writing that have 3 buttons with a background image for each button.
When the user touch one of the buttons I want that a green frame will appear around the the button for a 2 seconds and then disappear.
I know the I can build 2 separate images with and without the frame around the image but this will cause double the amount of files.
Is there any other way to do it?
Yes, you can add a border to any UIView (UIButton is a subclass of UIView) by accessing properties of the CALayer in the view:
button.layer.cornerRadius = 6; // if you want rounded corners
button.layer.borderWidth = 2;
button.layer.borderColor = [UIColor greenColor].CGColor;
You will need to import QuartzCore.h in the file to be able to reference the layer declarations:
#import <QuartzCore/QuartzCore.h>
You can turn on the border in response to the button's touch down (or up) event and then turn it off (borderWidth=0) with a timer.
i don't think there is a way to make it the way you want.
you have to make just two image, one when the button is not selected and the other when it's selected.
How to type a text in imgeview... right now successfully drawing using mouse. I need to type text in same image view using keyboard...
Try superimposing a UITextView on top of your UIImageView and set appropriate frames for both so that the text appears until where you want it to appear.
Set this property for your UITextView
myTextView.backgroundColor = [UIColor clearColor];
myTextView.textColor = [UIColor redColor]; //or whatever color you like based on the background image in your UIImageView.
Of course you will have to take care of the scrolling when the keyboard comes up after the UITextView becomes active.
If you want more assistance, please elaborate upon your question and your need.