Settitle:@"Button Title"Forstate:uicontrolstatehighlighted];//Highlight State - - //adds a click-triggered event to the button. the - [button addtarget:selfaction: @selector (touchButton1:) Forcontrolevents:uicontrol eventtouchup Inside]; - - //add a picture to a button + -[Button setimage:[uiimageimagenamed:@"Normal"] Forstate:uicontrolstatenormal];//normal state of the picture, PNG format can be added without suffix, jpg, etc., in case of unrecognized. + A //Adding a button to th
In iOS development, any visible view is inherited from the UIView. In the inheritance system, most of the UIView properties apply to any of their children.The Layer property of UIView can draw various effects of uiview. Actually the view animation we see is actually a layer in the drawing.1. Draw rounded Corners CornerView.layer.cornerRadius =; CornerView.layer.masksToBounds = YES;Maskstobounds prevents child elements from spilling over the parent view.If a square is to be set to a circle,
We often need to use buttons that require text and images to be displayed simultaneously, for example:We need to define a UIButton subclass.Implementation file-(ID) initWithFrame: (cgrect) frame{ self = [super initwithframe: frame];if (self) { //Can be adjusted according to your own needs self. Titlelabel. TextAlignment=nstextalignmentright;Self. Titlelabel. font=[uifontsystemfontofsize:14.0]; self. ImageView . Contentmode = Uiviewcontentmodeleft;}
The type of the button to be initialized when the button code is created is as follows:
Local play = uibutton: buttonwithtype (uibuttontypecustom) Play: setframe (cgrect (P [1], p [2], size. width, size. height) Play: setbackgroundimage_forstate (imgplay, 0) Play: addtarget_action_forcontrolevents (self, "ondeleteiconclick:", uicontroleventtouchupinside)
The event processing code is as follows:
Function ondeleteiconclick (self, Sender) puts (
On iOS, how does one align the button (UIbutton) text to the left? iosuibutton
// Button. titleLabel. textAlignment = NSTextAlignmentLeft; this sentence is invalid.
Button. contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
Button. titleEdgeInsets = UIEdgeInsetsMake (0, 10, 0, 0 );
I am always confused when I am working on the UI interface and how to align the text of the button to the left for display. Today I met again and de
Http://blog.csdn.net/yanxiaoqing/article/details/7230660
By default, all the effects that are not set are centered and the button is 150*150.
After using the following settings:
[Self settitleedgeinsets: uiedgeinsetsmake (0.0,-backgroundimag.
1. Create+ Buttonwithtype: // create and return a button of a specific style2. Set the titleButtontype PropertyTitlelabel property // view of the current title of the display button (read-only ). although it is read-only, its attributes are
First, double-click to import the required NGUI package.
The following is the import prompt. We need to import all of them here.
Project file after NGUI Import
After importing NGUI, The NGUI option will appear in the top menu bar.
In development, we often need to dynamically change the button label text, using the Settitle () function on it. Sometimes we need to switch between several headings, as shown in the example below, and the button text will switch between "play" and "
A.
B.
A. We can run the interface first. When looking for a file that can affect the interface, we can guess that the file can change the interface.
B. Find the target file, drag the control at will, and run the program to see the interface
1. Set the highlighted halo effect of the button being clicked
Code As follows:
[Cancelbutton
Setshowstouchwhenhighlighted :
Yes ];
2. Expand the touch response area with the button
the original code is as follows: menubtn. frame =
One: The default is the left picture right text
Two: Left text right picture (direct copy code to project can)
[Btn settitleedgeinsets:uiedgeinsetsmake (0,-btn.imageview.size.width, 0, Btn.imageView.size.width)];
[Btn
[Box.actionButton.layer Setmaskstobounds:yes];
[Box.actionButton.layer setcornerradius:10.0]; Set rectangle four fillet radius
//Border width
[box.actionButton.layer setborderwidth:1.0];
There are two ways to set the color of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.