SwitCommonのMessage弾窓


概要
Message弾窓は多くの場合、ヒント情報、エラー情報などが必要です.IOS 8では、UIAlertControllerクラスを使用してポップアップを管理する.
SCMessage
import Foundation
import UIKit

public typealias SCMessageBoxStyle = UIAlertControllerStyle
public typealias SCMessageBoxActionStyle = UIAlertActionStyle

public class SCMessageBox{

    /**
      UIAlertController  
    
    :param: title            
    :param: contentMsg       
    :param: boxStyle       :Alert  ActionSheet
    
    :returns: <#return value description#>
    */
    public class func boxController(title:String,contentMsg:String,boxStyle:SCMessageBoxStyle)->UIAlertController{
        return UIAlertController(title: title, message: contentMsg, preferredStyle: boxStyle)
    }
    
    /**
         UIAlertAction  
    
    :param: buttonString         
    :param: boxActionStyle     
    :param: blockHandler               
    
    :returns: <#return value description#>
    */
    public class func boxAction(buttonString:String,boxActionStyle:SCMessageBoxActionStyle,blockHandler:((UIAlertAction!) -> Void)!) -> UIAlertAction{
        return UIAlertAction(title: buttonString, style: boxActionStyle, handler: blockHandler)
    }

    /**
        Alert  
    
    :param: viewControl         (  Self    viewControl)
    :param: title                 
    :param: contentMsg          
    :param: buttonString        
    :param: blockHandler            
    */
    public class func show(viewControl:UIViewController,title:String,contentMsg:String,buttonString:String,blockHandler:((UIAlertAction!) -> Void)!){
        let control = self.boxController(title, contentMsg: contentMsg, boxStyle: SCMessageBoxStyle.Alert)
        let action  = self.boxAction(buttonString, boxActionStyle: SCMessageBoxActionStyle.Default, blockHandler: blockHandler)
        control.addAction(action)
        viewControl.presentViewController(control, animated: true, completion: nil)
    }
    /**
          Alert  (title=  ,buttonString=  )

    :param: viewControl        
    :param: contentMsg         
    */
    public class func showquick(viewControl:UIViewController,contentMsg:String){
        self.show(viewControl, title: "  ", contentMsg: contentMsg, buttonString: "  ", blockHandler: nil)
    }
    
}

Gitアドレス
http://devonios.com/go/swiftcommon
tips:
本文はwp 2 blogからインポートされ、原文リンク:http://devonios.com/scmessage.html