Common Properties for Ios4--uiview (size and position)

Source: Internet
Author: User
Tags set background

////VIEWCONTROLLER.M//Common Properties for 08-uiview (size and position)////frame: Positioned relative to the upper-left corner of the parent control//bounds: Change the length width, the upper left corner is relative to oneself//Center:#import "ViewController.h"@interfaceViewcontroller ()/** Label*/@property (nonatomic, weak) UILabel*label;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //Create a Uilabel objectUILabel *label =[[UILabel alloc] init]; //Set FRAME (position and size)Label.frame = CGRectMake ( -, -, -, -);//parent control as the origin point//Set Background colorLabel.backgroundcolor =[Uicolor Yellowcolor]; //add to view in controller[Self.view Addsubview:label];//add it in.Self.label =label;}-(ibaction) bounds {//after changing the size iOS9, the center point will not change, extending to the surroundingSelf.label.bounds = CGRectMake ( -, -, $, -);}-(ibaction) Center {//Change Position//self.label.center = cgpointmake (100, 100); //Show in the middleSelf.label.center = Cgpointmake (Self.view.frame.size.width *0.5, Self.view.frame.size.height *0.5); }-(ibaction) changeframe {//Mode 1//Self.label.frame = CGRectMake (200, 100, 100, 60); //Mode 2Self.label.frame = (CGRect) {{ -, -}, { -, -}}; //Mode 3//struct is a value pass, not an address pass//Self.label.frame.size.width + + +;CGRect frame =Self.label.frame;//frame.origin.x-=;//Change x Value//FRAME.ORIGIN.Y + + +;//Change the Y value//frame.size.width + =;//Change WidthFrame.size.height + = -;//Change HeightSelf.label.frame =frame; }@end

Common Properties for Ios4--uiview (size and position)

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.