UILable &UIImageView& UIButton布局

来源:互联网 发布:网络贷款利息计算器 编辑:程序博客网 时间:2024/06/01 09:03

#import "ViewController.h"


@interface ViewController ()


{

    

    UILabel*lable;

   

}


@end


@implementation ViewController


- (void)viewDidLoad {

    [superviewDidLoad];

    lable=[[UILabelalloc ]initWithFrame:CGRectMake(80, 300, 200, 200)];

    lable.text=@"我是一个坚强的人";

    lable.textColor=[UIColorblackColor];

    lable.backgroundColor=[UIColor redColor];

    lable.textAlignment=NSTextAlignmentCenter;

    lable.numberOfLines=0;

    lable.font=[UIFontsystemFontOfSize:30];

    [self.viewaddSubview:lable];

    

   

    UIImageView*imageView=[[UIImageViewalloc]init];

    imageView.frame=CGRectMake(80, 20, 200, 200);

    imageView.layer.masksToBounds=YES;

    imageView.layer.cornerRadius=100;

    [imageView setImage:[UIImageimageNamed:@"Cachestemp (1).jpg"]];

    

    [self.viewaddSubview:imageView];

    

    UIButton*button=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];

    button.frame=CGRectMake(130, 600, 100, 50);

    button.backgroundColor=[UIColorgreenColor];

    [button setTitle:@"点击"forState:UIControlStateNormal];

    [button setTitleColor:[UIColorblackColor]forState:UIControlStateNormal];

    //[button setFont:[UIFont systemFontOfSize:20]];

    button.layer.masksToBounds=YES;

    button.layer.cornerRadius=10;

    [self.viewaddSubview:button];

    [button addTarget:selfaction:@selector(gaibian)forControlEvents:UIControlEventTouchUpInside];

    

    

    

    

    

    

    

    

    

    // Do any additional setup after loading the view, typically from a nib.

}


-(void)gaibian{

    

    lable.text=@"其实我是一个暖男,时间久了你就会爱上我的,不信你试试?";

    NSLog(@"fubaibijindemeinvdengwolaicao");

    

    

}





- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


1 0
原创粉丝点击