0
在我的应用程序中,我有一个地图视图,我想在地图上显示一个自定义按钮,如果放置按钮,它会显示,但是,如果我为图像放置背景图像,它不会被打印。按钮没有显示?
UIButton *customButton = [UIButton buttonWithType: UIButtonTypeCustom];
[customButton setBackgroundImage:[UIImage imageNamed:
@"Button_Default.png"]
forState:UIControlStateNormal];
[customButton setBackgroundImage:[UIImage imageNamed:
@"Button_Highlighted.png"]
forState:UIControlStateHighlighted];
[customButton setFrame:CGRectMake(60, 100, 200, 40)];
[self.view addSubview:customButton];
我自己也尝试将最后一行的
[mapView addSubview:customButton];
你能替换“[customButton setBackgroundImage:[UIImage imageNamed: @”Button_Highlighted.png“] forState:UIControlStateHighlighted];”与“[customButton setBackgroundImage:[UIImage imageNamed: @”Button_Highlighted.png“] forState:UIControlStateNormal];”并请让我知道..如果它的工作与否 – nikhilgohil11
请确保您的资源文件夹中的资源,如“Button_Default.png”和“Button_Highlighted.png” –
我相信我正在使用.png文件 – chandru