Two rectangles that iOS does intersect

Source: Internet
Author: User



#import "ViewController.h"

@interface Viewcontroller ()
{
UIView *_gee; The defined instance variable
UIView *_red;
}

@end

@implementation Viewcontroller

-(void) Viewdidload {
[Super Viewdidload];


    cgrect ret = CGRectMake (+,--); A rectangular coordinate and a length-width
    _gee = [self Creatview:ret color:[uicolor Greencolor]]; Call the following function to make the rectangle color green
    cgrect Ret1 = CGRectMake (200, 200, The The coordinates of the other rectangle are long-width
    _red = [self Creatview:ret1 color:[uicolor Redcolor ]];//Rectangle color is red
    


}
-(UIView *) Creatview: (cgrect) ret color: (Uicolor *) colol{//Set the name of the rectangle and the structure of the color
UIView *v = [[UIView alloc] initwithframe:ret];//The matrix is initialized with a pointer to V,
V.BACKGROUNDCOLOR = Colol;//The background color of this matrix is represented by a color method
[Self.view addsubview:v]; Let the color of the setting show up on the monitor
return v;
}
-(Ibaction) Biand: (ID) Sender {//This is a key method
[Self.view exchangesubviewatindex:3 withsubviewatindex:4]; Using array methods to exchange two matrices successively

}

-(void) didreceivememorywarning {
[Super didreceivememorywarning];
Dispose of any resources the can be recreated.
}

@end

Two rectangles that iOS does intersect

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.