2011-03-04 35 views
1

我想稍微定制一个UIActionSheet;只需在现有的2个按钮之上添加一个自定义的UIButton/UIImageView,就像之前的文章一样,但是使用自定义按钮/图像而不是默认按钮上方的文本。我尝试添加一个简单的UILabel以查看它是否正常工作:UIActionSheet Customization如何使用默认按钮将自定义控件添加到ActionSheet?

UIActionSheet *actionSheet = [[UIActionSheet alloc] 
        initWithTitle: @"" 
          delegate: self  
       cancelButtonTitle: NSLocalizedString(@"Cancel",@"cancel button") 
      destructiveButtonTitle: nil 
       otherButtonTitles: @"Send",nil]; 

actionSheet.tag = kCallActionSheetTag; 

UILabel *btn = [[UILabel alloc] initWithFrame: 
         CGRectMake(18, 10, 140, 50)]; 
accountLabel.textAlignment = UITextAlignmentLeft; 
accountLabel.textColor = [UIColor whiteColor]; 
accountLabel.text = @"Account"; 
accountLabel.font = [UIFont boldSystemFontOfSize:16]; 
accountLabel.backgroundColor = [UIColor clearColor]; 
[actionSheet addSubview:accountLabel]; 
[accountLabel release]; 
[actionSheet showInView:self.tabBarController.view]; 
[actionSheet setBounds:CGRectMake(0,0,320, 260)]; 
[actionSheet release]; 

如果我使用上面的代码中,两个按钮被垂直向上移动和UILabel重叠顶部按钮。他们似乎被锁定在操作单的顶部。我宁愿不添加我自己的按钮并定位它们。做这个的最好方式是什么?

感谢

回答

0

这里是我的建议,

我的经验是从UIAlertView中,我没有测试过。

它应该设置巨大的顶部消息偏移按钮y偏移量。

然后添加您的UILabel

相关问题