// // InfoByImageViewController.m // Ifish // // Created by 祝发冬 on 2020/6/20. // Copyright © 2020 lianlian. All rights reserved. // #import "InfoByImageViewController.h" @interface InfoByImageViewController () @end @implementation InfoByImageViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.imageView=[[UIImageView alloc]initWithFrame:CGRectZero]; [self.view addSubview:self.imageView]; [ self.imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); make.right.mas_equalTo(0); }]; if (self.image) { self.imageView.image=self.image; } if (self.title) { self.titleString=self.title; } if ([self.type isEqualToString:@"service"]) { UIButton*xuanduo=[UIButton buttonWithType:UIButtonTypeSystem]; [self.view addSubview:xuanduo]; [xuanduo mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.height.mas_equalTo(self.view.frame.size.height/12); make.right.mas_equalTo(0); }]; xuanduo.tag=1; xuanduo.backgroundColor=[UIColor clearColor]; [xuanduo addTarget:self action:@selector(service:) forControlEvents:UIControlEventTouchUpInside]; UIButton*reuxin=[UIButton buttonWithType:UIButtonTypeSystem]; [self.view addSubview:reuxin]; [reuxin mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(4*self.view.frame.size.height/12-25); make.height.mas_equalTo(self.view.frame.size.height/12); make.right.mas_equalTo(0); }]; reuxin.tag=2; reuxin.backgroundColor=[UIColor clearColor]; [reuxin addTarget:self action:@selector(service:) forControlEvents:UIControlEventTouchUpInside]; UIButton*songnuo=[UIButton buttonWithType:UIButtonTypeSystem]; [self.view addSubview:songnuo]; [songnuo mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(8*self.view.frame.size.height/12-25); make.height.mas_equalTo(self.view.frame.size.height/12); make.right.mas_equalTo(0); }]; songnuo.tag=3; songnuo.backgroundColor=[UIColor clearColor]; [songnuo addTarget:self action:@selector(service:) forControlEvents:UIControlEventTouchUpInside]; } } -(void)service:(UIButton*)button { NSURL*url; if (button.tag==1) { url=[NSURL URLWithString:@"tel://17321129273"]; } else if (button.tag==2) { url=[NSURL URLWithString:@"tel://4000121101"]; } else if (button.tag==3) { url=[NSURL URLWithString:@"tel://13392205468"]; } if (@available(iOS 10.0, *)) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; }else { [[UIApplication sharedApplication] openURL:url]; } } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end