iOS Development UI Basic Learning-------Summary

Source: Internet
Author: User

    • What is a control?

      • All UI elements on the screen are called controls (also called views, components)
    • Common properties of the control

      • Size
      • Position
      • Background color
      • ...
    • Apple extracts the common properties of the control into the parent class UIView

      • All controls are eventually inherited from UIView
Parent-child controls
    • Each control is a container that can hold other controls
    • The inner gizmo is a child of the large control
Common Properties
    • Get your own parent control object

        @property ( nonatomic,retain)
       uiview *superview;     
    • Gets all of its child control objects-the order of the array elements determines the display level of the child controls

        @property ( Span class= "Hljs-keyword" >nonatomic,readonly,copy) nsarray *subview;       
    • -(void) Addsubview: (UIView *) view;

      • Add a child control view
      • Example:-(ibaction) ButtonClick {Uiswitch *s = [[Uiswitch alloc]init]; [Self.view addsubview:s]; }
    • (void) Removeformsuperview;

      • Remove the
    • from the parent control
    • -(UIView *) Viewwithtag: (nsinteger) tag;

      • finds the corresponding control (usually child controls) based on a tag identity
    • -(UIView *) Viewwithtag: (nsinteger) tag;

      • finds the corresponding control (usually child controls) based on a tag identity
//CGRect是一个结构体,有四个小属性,位置坐标和大小//控件矩形框在父控件中得位置和尺寸(以父控件的左上角为坐标原点)//向右为x正方向,纵向向下为y轴正方向。x,y分别表示距矩形边框的距离- @property(nonatomic)CGRect frame;- @property(nonatomic)CGRect bounds;//控件矩形框的位置和尺寸(以自己左上角为坐标原点,所以bounds的x、y一般为0)- @proerty(nonatomic)CGPoint center;//控件中点的位置(以父控件的左上角为坐标原点)


Watch out.
    • When the button is set, the Type property is initially in the system state, which is dimmed when the button is clicked.
    • You need to set the Type property to custom when you define a button that is highlighted, unavailable, and so on.

Display indicator
    • Several ways to hide controls
self.addBtn.hidden = YES;  设置为隐藏self.addBtn.alpha = 0; 设置透明度,默认是1.0(100%不透明)[self.addBtn removeFormSuper]; 直接删除

The SEL type is actually the wrapper for the method @selector (method name)

Ways to implement Timers

    • Method 1:performselector
      [self performSelector:@selector(hideHUD) withObject:nil afterDelay:2.0]参数一:SEL方法参数二:参数参数三:?s延迟
    • Method 2:GCD
    • Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (1.5 * nsec_per_sec)), Dispatch_get_main_queue (), ^{

        self.hud.alpha = 0.0;

      });

    • Method 3:nstimer (When Repeats=yes, the method is called every 1.5s)

    • [Nstimer scheduledtimerwithtimeinterval:1.5 target:self selector: @selector (*) Userinfo:nil Repeats:no];
Hud
    • Other claims: indicator, masking, masking
    • Semi-transparent HUD procedure:
      • Background color set to translucent color
Problems
    • A. m file inside the project cannot be used-:build phases, Complie Sources

    • A resource file within the project (such as plist, audio, etc.) cannot be used

      • Check: Build phases, Copy Bundle Resource
      • What is a model?
      • Objects that are designed to hold data
      • are generally pure objects that are directly integrated with NSObject
      • Some properties are provided internally to hold the data

iOS Development UI Basic Learning-------Summary

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.