//
// ViewController.m
// UIButtonImage
//
// Created by apple on 2021/11/17.
// Copyright © 2021 apple. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button1.frame =CGRectMake(40, 100, 310, 60);
UIImage *image = [UIImage imageNamed:@"button"];
[button1 setBackgroundImage:image forState:UIControlStateNormal];
[button1 setTitle:@"Click Me" forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
button1.titleLabel.font = [UIFont fontWithName:@"Arail" size:24];
[button1 addTarget:self action:@selector(buttonClick:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview:button1];
}
-(void) buttonClick:(UIButton *)bt
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Infomation" message:@"buttonClick" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *OKAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:OKAction];
[self presentViewController:alert animated:YES completion:nil];
}
@end