现在的位置: 首页 > 综合 > 正文

给UIButton添加title和image

2014年03月12日 ⁄ 综合 ⁄ 共 412字 ⁄ 字号 评论关闭

    UIButton *btnTwo = [UIButton
buttonWithType:UIButtonTypeRoundedRect]; 

    btnTwo.frame =
CGRectMake(40,
140, 80,
40
);

   
UIImage *btnImage = [UIImage
imageNamed:@"icon.png"];

    [btnTwo
setBackgroundImage:btnImage forState:UIControlStateNormal];

    [btnTwo
setTitle:@"Title"
forState:UIControlStateNormal];

    [btnTwo
addTarget:self
action:@selector(goToOne)
forControlEvents:UIControlEventTouchUpInside];

    [self.view
addSubview:btnTwo];

    

抱歉!评论已关闭.