在XIB文件中创建带有图像的后退按钮

时间:2016-07-25 09:42:40

标签: ios iphone

我想设计类似于附加屏幕设计的back button。单击后退按钮主屏幕出现。我该怎么做?注意:不使用导航栏

1 个答案:

答案 0 :(得分:0)

使用以下代码创建按钮。

UIButton yourButton = [UIButton buttonWithType:UIButtonTypeCustom];
[yourButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[yourButton setTitle:@"BACK" forState:UIControlStateNormal];
[yourButton setImage:[UIImage imageNamed:@"back_arrow_image_name.png"] forState:UIControlStateNormal];
[yourButton setBackgroundImage:[UIImage imageNamed:@"bg_image_name.png"] forState:UIControlStateNormal];
[yourButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];



-(void)backButtonClicked:(UIButton*)sender
{
     //code for navigate to home page
}