2011-03-04 42 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

相關問題