UIView CGRect CGPoint

CGRect

struct CGRect {

  CGPoint origin;//起始点为以此点确定图形左上角位置
  CGSize size;

};


struct CGPoint {
  CGFloat x;
  CGFloat y;
};


struct CGSize {
  CGFloat width;
  CGFloat height;
};


CGRect bounds = self.view.bounds;
    NSLog(@"X=%f",bounds.origin.x); //X=0.000000
    NSLog(@"Y=%f",bounds.origin.y);//Y=0.000000
    NSLog(@"midX%f",CGRectGetMidX(bounds));//midX160.000000
    NSLog(@"midY%f",CGRectGetMidY(bounds));//midY230.000000

CGRect labelFrame = CGRectMake(bounds.origin.x,bounds.origin.y,
                                   bounds.size.width, 100);
    self.label = [[[UILabel alloc] initWithFrame:labelFrame] autorelease];
    self.label.center = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
    self.label.font = [UIFont fontWithName:@"Helvetica" size:70];
    self.label.text = @"Bazinga!";
    self.label.textAlignment = UITextAlignmentCenter;
    self.label.backgroundColor = [UIColor clearColor];
     [self.view addSubview:label];



你可能感兴趣的:(struct,UIView,图形)