Common Properties of UIView

Source: Internet
Author: User
Tags uicontrol word wrap

UIVIew Common Properties 1.frame position and dimensions (in the upper left corner of the parent control is the origin (0,0))2.center midpoint (in the upper left corner of the parent control is the origin (0,0))  3.bounds         < Span style= "color: #800080;" > location and dimensions           0,0           4  . Transform Deformation Properties
cgaffinetransform (make)scale: Scaling cgaffinetransformrotate (makerotation): Rotate Cgaffinetransform (Make) Translate: Panning
5. backgroundcolor Background Color6. Tag ID (the parent control can find the corresponding child control based on this identity, not the same as a child control in the same parent control)7. Hidden set Whether you want to hide8.alpha Transparency (0~1);9.opaque Opacity (0~1);10. userinteractionenabled can interact with the user (YES can interact)11. Superview Parent Control12. Subviews child controls13. Contentmode the mode stretch adaptation of the content display [view Viewwithtag:10]; [BTN19Btn210ImageView210] Two. UIView Common methods1. Addsubview adding child controls, added to the top (last face in Subviews)2. Removefromsuperview removal from parent control3. Viewwithtag: The parent control can find the corresponding control (traversing all child controls) based on this tag identity4. Insertsubview:atindex: Adding child controls to the specified location5Two ways to perform an animation using two class methods + (void) Beginanimations: (NSString *) Animationid Context: (void *) context;/**.. Code to perform the animation: **/+(void) Commitanimations;6. Performing animations with Blok/*Duration animation Duration Animations Store the code that needs to be animated by the forest completion the action code to be executed when the animation is complete*/+ (void) Animatewithduration: (nstimeinterval) Duration animations: (void (^) (void)) Animations completion: (void (^)) (BOOL finished) completion
7. Overriding the initialization method
//Call when writing a view with code
-(ID) initWithFrame: (CGRect) Frame
{
Self = [Super Initwithframe:frame];
if (self) {
v = [[UIView alloc] Initwithframe:cgrectmake (0, 0, 0, frame.size.height)];
V.backgroundcolor = [Uicolor orangecolor];
[self addsubview:v];
    }
return self;
}

Called when creating a view with storyboard
-(ID) Initwithcoder: (Nscoder *) Adecoder
{
if (self = [Super Initwithcoder:adecoder]) {
v = [[UIView alloc] Initwithframe:cgrectmake (0, 0, 0, self.frame.size.height)];
V.backgroundcolor = [Uicolor orangecolor];
[self addsubview:v];
    }
return self;
}Three. Uicontrol1As long as you inherit Uicontrol, you can simply handle the event (click event, Value Change event)2. inherits the subclass UIButton.UISlider.UISwitch of the Uicontrol. Uidatepicker, wait.3When you need to listen for a child control time, the steps to resolve:1>First see if it inherits from Uicontrol.2>And see if it has a delegate property inside it.4. Common Properties1>Enabled can process time2>Contentverticalalignment how content is arranged in the vertical direction3>Contenthorizontalalignment how content is arranged in a horizontal direction5. Common methods1>Add Listener/*The method that the target listener object invokes when the action event fires, calling the target method*/-(void) AddTarget: (Id) Target action: (SEL) Action forcontrolevents: (uicontrolevents) controlevents;2>Delete Listener//After the listener is deleted, the listener is no longer notified when the event is triggered, and the target's action method is no longer invoked-(void Roemovetarget: (IdTarget action:] (SEL) Action forcontrolevents:] (uicontrolevents) controlevents);3>Get all Listener objects-(Nsset *) Alltargets; four, UILabel11>text The text content displayed 2>textcolor text color 3> font fonts 4>< Span style= "color: #000000;" > Shadowcolor the shadow color of the text 5>6>7>numberoflines allows up to a few lines of text (if 0, word wrap). Five. UIButton //1
1>Titlelabel gets the internal Uilabel object2>ImageView gets the internal Uiimageview object2. Common methods1>Set the text content for internal Uilabel display//The button text cannot be btn when set. Titlelabel.text = @ "4324324";-(void) Settitle: (NSString *) title forstate: (uicontrolstate) state;//Default is nil. Title is assumed2>Sets the text color of the internal Uilabel-(void) Settitlecolor: (Uicolor *) color forstate: (uicontrolstate) state ui_appearance_selector;//Default if nil. Use opaque white3>Sets the text shadow color of the inner Uilabel-(void) Settitleshadowcolor: (Uicolor *) color forstate: (uicontrolstate) state ui_appearance_selector;//Default is nil. Use 50% Black4>Set the picture of the internal Uiimageview-(void) SetImage: (UIImage *) image forstate: (uicontrolstate) state;//Default is nil. Should is same size if different for different states5>Set the picture of the internal Uiimageview-(void) SetBackgroundImage: (UIImage *) image forstate: (uicontrolstate) state ui_appearance_selector;//Default is Nil6>The following two methods need to be handed over to subclasses to rewrite//Returns the frame (position and size) of the Uilabel without the control unit-(CGRect) Titlerectforcontentrect: (CGRect) Contentrect;// Returns the size and position of the internal uiimage- ( CGRect) Imagerectforcontentrect: (CGRect) Contentrect; 7> These methods can get some properties in different states-(NSString *) titleforstate :(uicontrolstate) state; // These getters only take a single state value-(Uicolor *< Span style= "color: #000000;" >) Titlecolorforstate: (uicontrolstate) state;-(uicolor *) Titleshadowcolorforstate: ( uicontrolstate) state;-(UIImage *) Backgroundimageforstate: (uicontrolstate) state;-(nsattributedstring *) Attributedtitleforstate: (UIControlState) State Ns_available_ios (6_0);           
 

Common Properties of UIView

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.