iOS alertController之actionsheet样式添加控件(类似自定义actionsheet)

来源:互联网 发布:淘宝一件代发有人下单 编辑:程序博客网 时间:2024/05/19 13:10

“`python

 NSString*title=UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;UIAlertController*alert=[UIAlertController alertControllerWithTitle:@"快速兑换" message:title preferredStyle:UIAlertControllerStyleActionSheet];UIAlertAction*action=[UIAlertAction actionWithTitle:@"立即兑换" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {}]; UIAlertAction*action1=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancelhandler:^(UIAlertAction * _Nonnull action) { }];   [alert addAction:action];   [alert addAction:action1];    UIView*img=[[UIView alloc]init];img.frame=CGRectMake(5,40, SCREEN_WIDTH-30, 220);//    img.backgroundColor=[UIColor redColor];[alert.view addSubview:img];goodsname=@"123456手表";costCount=@"2000";totalCount=@"8000";lastCount=@"6000";NSString*str=[NSString stringWithFormat:@"立即兑换%@,消费%@积分,您当前账户剩余%@积分,兑换后剩余%@积分,点击下方的【立即兑换】按钮即可兑换。",goodsname,costCount,totalCount,lastCount];cnvUILabel*label=[[cnvUILabel alloc]initWithFrame:CGRectMake(15, 10, img.frame.size.width-30, [self getHeightWithString:str fontSize:15])];NSLog(@"---%f",[self getHeightWithString:str fontSize:15]);label.font=[UIFont systemFontOfSize:15];[img addSubview:label];[label cnv_setUILabelText:str andKeyWord1:goodsname andKeyWord2:costCount andKeyWord3:totalCount andKeyWord4:lastCount andKeyword5:@"【立即兑换】"];[label cnv_setUIlabelTextColor:[UIColor blackColor] andKeyWordColor:[UIColor redColor]];UIImageView*imagev=[[UIImageView alloc]initWithFrame:CGRectMake(15, 110, 100, 100)];imagev.image=[UIImage imageNamed:@"u1526"];StoreImageView*imgg=[[NSBundle mainBundle]loadNibNamed:@"StoreImageView" owner:nil options:nil][0];[imgg resetFrame:CGRectMake(15, 110, img.frame.size.width-30, 100)];imgg.storeImage.image=[UIImage imageNamed:@"u1526"];imgg.storeName.text=goodsname;imgg.count.text=costCount;imgg.lastGoods.text=@"剩10件";//    [imgg drawRect:CGRectMake(15, 110, img.frame.size.width-30, 100)];[img addSubview:imgg];[self presentViewController:alert animated:YES completion:^{}];

“`
示例图

0 0