文コード呼び出しプロンプトボックス

4024 ワード

効果図(ps:効果図がなくて、どのように見ることができます)
FQ_AlertTipView.gif
前言:ただちょうど他の人のAppのカスタマイズの弾枠を见るのはとても悪くありません.自分で少し时间をかけてカプセル化しました.縦横のスクリーンの切り替えを支持します!
紹介:
 -------------------     ----------------------
   typedef NS_ENUM (NSInteger, FQ_AlertType)
  {
  FQ_AlertTypeActionAlert = 0 ,  //  
  FQ_AlertTypeActionTop ,        //  
  FQ_AlertTypeActionSheet,       //  
  };

 -------------------Action  ----------------------
 typedef NS_ENUM (NSInteger, FQ_AlertActionType)
{
FQ_AlertActionStyleDefault = 0, //    
FQ_AlertActionStyleConfirm,     //    
FQ_AlertActionStyleDestructive,  //    
FQ_AlertActionStyleCancel  //    
 };  

主な3つのクラス:
1.コンフィギュレーションクラス:FQ_AlertConfiguration.豊富にする必要がある場合.どんな文字の余白などを追加することができます.私はデフォルトの処理をしました
 //FQ_AlertActionStyleDefault = 0, //    
  @property (strong, nonatomic) UIColor *defaultTextColor;
  @property (strong, nonatomic) UIColor *defaultBackgroundColor;
  @property (strong, nonatomic) UIFont  *defaultTextFont;`
  ......
  @property (assign, nonatomic) CGFloat cornerRadius;
  //       .   .(    swift     )
  @property (class, nonatomic)  FQ_AlertConfiguration *defaultConfiguration;

2.レスポンスコントロール構成クラス:FQ_AlertAction.実はボタン
  `  //   .
    + (instancetype)actionWithTitle:( NSString *)title type:(FQ_AlertActionType)actionType handler:(void (^)(FQ_AlertAction *action))handler;`

3.展示類:FQ_AlertView.
 /**
          
  @param title   
  @param message     
  @param alertType     
  @param confirmActionStr   Action    
  @param otherActionStrArr   Action      
  @param destructiveActionStr   Action    
  @param configuration     
  @param actionBlock   Action  
  @return AlertView
   */
  + (instancetype)showAlertViewWithTitle:(NSString *)title
                             message:(NSString *)message
                           alertType:(FQ_AlertType)alertType
                    confirmActionStr:(NSString *)confirmActionStr
                   otherActionStrArr:(NSArray *)otherActionStrArr
                  destructiveActionStr:(NSString *)destructiveActionStr
                   cancelActionStr:(NSString *)cancelActionStr
                       configuration:(FQ_AlertConfiguration*)configuration
                         actionBlock:(void(^)(FQ_AlertAction * action))actionBlock;

その他のクラス
1.管理クラス:FQ_AlertViewManager.現在のインタフェースにFQalertViewコントロールが1つしか表示されないことを保証する.一般的には同時に発生しない場合がある.
2.工具類:FQ_AlertWindowVc.弾枠ContentViewはUIWindowを使用する.縦画面切替処理に用いる.
次の操作を行います.
1.ショートカット作成方式:一言で解決
    [FQ_AlertView showAlertViewWithTitle:@"   "  message:@"      !               ?"  alertType:FQ_AlertTypeActionSheet confirmActionStr:@"  " otherActionStrArr:nil destructiveActionStr:nil cancelActionStr:@"  " configuration:nil actionBlock:^(FQ_AlertAction *action) {
        NSLog(@"action= %@",action.title); //            Action     
       }];

2.カスタム作成:(アップルの作成を参照)
    FQ_AlertView * alertView =  [FQ_AlertView showAlertViewWithTitle:@"  ?" message:@"    XXXXXXXXXXXXXXXXXXXX,   ?" alertType:FQ_AlertTypeActionSheet configuration:nil];
    FQ_AlertAction * test = [FQ_AlertAction actionWithTitle:@"  " type:FQ_AlertActionStyleConfirm handler:^(FQ_AlertAction *action) {
        NSLog(@"    ");
    }];
    FQ_AlertAction * test1 = [FQ_AlertAction actionWithTitle:@"       " type:FQ_AlertActionStyleConfirm handler:^(FQ_AlertAction *action) {
        NSLog(@"         ");
    }];
    FQ_AlertAction * test2 = [FQ_AlertAction actionWithTitle:@"  " type:FQ_AlertActionStyleCancel handler:^(FQ_AlertAction *action) {
        NSLog(@"    ");
    }];
    [alertView addAction:test];
    [alertView addAction:test1];
    [alertView addAction:test2];
    [alertView showAlertView];

END:githubアカウントにアップロードされていません!メッセージが必要です!