Подтвердить что ты не робот

Как реализовать кнопку с программным обеспечением backgroundimage в iphone

Я разрабатываю образы с помощью кнопки программно в iphone. теперь я хочу добавить кнопку backgroundimage для следующих и предыдущих кнопок. Я хочу добавить изображения для этих кнопок программно.

как добавить изображение кнопки в iphone.

4b9b3361

Ответ 1

//Добавьте кнопку, подобную этой

UIImage *redButtonImage = [UIImage imageNamed:@"ExitButton.png"];

        UIButton *redButton = [UIButton buttonWithType:UIButtonTypeCustom];
        redButton.frame = CGRectMake(280.0, 10.0, 29.0, 29.0);
        [redButton setBackgroundImage:redButtonImage forState:UIControlStateNormal];

        [view addSubview:redButton];

Ответ 2

вы можете попробовать это

 UIImage *buttonImage = [UIImage imageNamed:@"image.png"];

//create the button and assign the image
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];


//create a UIBarButtonItem with the button as a custom view
//UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];

[button addTarget:self action:@selector(clickActionItem:) forControlEvents:UIControlEventTouchUpInside];

удача

Ответ 3

используйте это для установки изображения в вашей кнопке

[yourButton setBackgroundImage:yourImage forState:UIControlStateNormal];

Ответ 4

Попробуйте это,

UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeCustom];
yourButton.frame = CGRectMake(0, 0, 80, 40);
[yourButton setBackgroundImage:[UIImage imageNamed:@"backgroungImage.png"] forState:UIControlStateNormal];
[self.view yourButton];