2017-12-19 7 views
1

私は下の画像のようなカラー/サイズの画像/アイコンを望むもの、this question .iの内側に1が好きではありませリンゴの音楽プレーヤー内のダイアログのようUIAlertControllerXcode UIAlertControllerオプションにイメージを追加する方法を教えてください。

を画像/アイコンを追加したいが、そのIOS 11+機能を信じます私はそれのためのドキュメントを見つけることができません。まさにこのような

は:

enter image description here

私はUIAlertControllerでこれを行うことができますか私は私自身のカスタムダイアログuiviewcontrollerをしなければなりませんか? the4kman @

+0

その、ある小さな画像を持って、私が欲しい1の答えが同様にカラー化画像を扱う:) – Jack

+0

同じサイズで画像を着色している​​私はウルリンクに質問を見た重複していません。 – the4kman

+0

あなたは私の答えのオプションの中に私の色付きのイメージを表示することはできますか? – Jack

答えて

1
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)    
alert.modalPresentationStyle = .popover 


let image = UIImage(named: "logoCircle") 
let imageView = UIImageView() 
imageView.image = image 
imageView.frame = CGRect(x: 25, y: 18, width: 24, height: 24) 
alert.view.addSubview(imageView) 

let image1 = UIImage(named: "icshare") 
    let imageView1 = UIImageView() 
    imageView1.image = image1 
    alert.view.addSubview(imageView1) 
    imageView1.frame = CGRect(x: 25, y: 75, width: 24, height: 24) 

let shareExternal = UIAlertAction(title: NSLocalizedString("Share External Link", comment: ""), style: .default) { action in 
     } 
let shareInApp = UIAlertAction(title: "Share within", style: .default) { 
       action in 
      } 

    alert.addAction(shareInApp) 
    alert.addAction(shareExternal) 


    if let presenter = alert.popoverPresentationController 
    { 
      presenter.sourceView = button 
      presenter.sourceRect = button.bounds 
    } 
    present(alert, animated: true, completion: nil) 
+0

ここで私は 'UIAlertController'ビューで画像を追加します!その仕事をしましたが、上記の画像と同じように複数のオプションにする必要があります。+1はアイデア – Jack

+0

@Jackです。更新された回答を確認する –

関連する問題