在UIActionSheet上添加UIView作为子视图
我正在项目中,我想要显示UIActionsheet三个button更改,取消和完成,在标题的地方,我想把UIView有一些标签。 我已经创build了dynamic的UIView,我把它添加到动作表,但它隐藏在button后面,我试图通过所有可能的方式setFrame,但我无法find解决scheme。 我想把这个UIView放在UIActionsheet的顶部,然后是button。 如果您有任何疑问,请随时发表评论。
这是我的代码:
-(IBAction)tapbutton:(id)sender { Lablesubview *view = [[Lablesubview alloc]init]; UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Change" otherButtonTitles:@"Done",nil]; [actionSheet addSubview:view]; [actionSheet showInView:self.view]; }
您可以使用这种方法,它会将所有的button向下移动100像素,请注意,这种修改可能会导致您的应用程序被拒绝
-(IBAction)tapbutton:(id)sender { //create the view Lablesubview *view = [[Lablesubview alloc]init]; //Set the frame view.frame = CGRectMake(0, 10, 320, 100); view.backgroundColor = [UIColor greenColor]; UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Change" otherButtonTitles:@"Done",nil]; [actionSheet showInView:self.view]; CGRect rect; //expand the action sheet rect = actionSheet.frame; rect.size.height +=100; rect.origin.y -= 100; actionSheet.frame = rect; //Displace all buttons for (UIView *vButton in actionSheet.subviews) { rect = vButton.frame; rect.origin.y += 100; vButton.frame = rect; } //Add the new view [actionSheet addSubview:view]; }