CDAlertView:使用简洁、可定制 Alert 组件

tixe2911 8年前
   <p><img src="https://simg.open-open.com/show/aa1db3d2960e76b75b5d56fce0ae464c.png"></p>    <p>CDAlertView is highly customizable alert popup written in Swift 3. Usage is similar to UIAlertController .</p>    <h3><strong>Screenshots</strong></h3>    <p style="text-align:center"><img src="https://simg.open-open.com/show/3b5b681b9be6434781238a1a879cdacd.png"></p>    <h3><strong>Animations</strong></h3>    <p style="text-align:center"><img src="https://simg.open-open.com/show/cfd44e1e10de6285f9b22976fa2eb925.gif"> <img src="https://simg.open-open.com/show/5e25130a1e3eeb18b0335e16f693fd87.gif"> <img src="https://simg.open-open.com/show/13e58c9edc6028f5a46214a82ef312d1.gif"></p>    <h2><strong>Usage</strong></h2>    <p>Basic usage without any buttons:</p>    <pre>  <code class="language-objectivec">CDAlertView(title: "Awesome Title", message: "Well explained message!", type: .notification).show()</code></pre>    <p>NOTE:You can use it without buttons. Touch outside of the popup or move it will disappear it if there is no action button. If there is an action button, only pressing button will disappear it.</p>    <p>To add new buttons:</p>    <pre>  <code class="language-objectivec">let alert = CDAlertView(title: "Awesome Title", message: "Are you in?!", type: .notification)  let doneAction = CDAlertViewAction(title: "Sure! :muscle:")  alert.add(action: doneAction)  let nevermindAction = CDAlertViewAction(title: "Nevermind :expressionless:")  alert.add(action: nevermindAction)  alert.show()</code></pre>    <p>CDAlertView types:</p>    <pre>  <code class="language-objectivec">public enum CDAlertViewType {      case error, warning, success, notification, alarm, empty  }</code></pre>    <h2><strong>Initialization</strong></h2>    <h3><strong>Advanced Alert Initialization</strong></h3>    <p>To use it with your custom icon, initialize without type (or with .empty) and set your icon and background color:</p>    <pre>  <code class="language-objectivec">let alert = CDAlertView(title: "Awesome Title", message: "Well explained message!", type: .custom(image: UIImage(named:"YourAwesomeImage")))  alert.circleFillColor = UIColor.yourAmazingColor</code></pre>    <h3><strong>List of Available CDAlertView Options</strong></h3>    <p>titleTextColor: UIColor -> Sets title's text color</p>    <p>messageTextColor: UIColor -> Sets message's text color</p>    <p>titleFont: UIFont -> Sets title's font</p>    <p>messageFont: UIFont -> Sets message's font</p>    <p>isHeaderIconFilled: Bool -> Chooses filled icons instead of outline ones. Default is false .</p>    <p>alertBackgroundColor: UIColor -> Sets popup's background color.</p>    <p>popupWidth: CGFloat -> Width of the popup view</p>    <p>hasShadow: Bool -> Apply shadows around the popup. Defualt is true .</p>    <p>circleFillColor: UIColor -> Sets background color of header icon. (Color of circle area)</p>    <p>isActionButtonsVertical: Bool -> Alignes action buttons vertical. Default is false . Maximum number of horizontal buttons is 3.</p>    <h3><strong>Advanced action initialization:</strong></h3>    <p>font , textColor , backgroundColor , handler are all optional and has default parameter values. You can initilize with them or set them after initialization.</p>    <pre>  <code class="language-objectivec">let action = CDAlertViewAction(title: "Action Title", font: UIFont.yourCustomFont, textColor: UIColor.yourTextColor, backgroundColor: UIColor.yourBackgroundColor, handler: { action in })  alertView.addAction(action)</code></pre>    <p>NOTE:Aligning buttons vertical and horizontal is possible. But using more than 3 buttons in horizontal placement is not possible.</p>    <h3><strong>List of CDAlertViewAction Options</strong></h3>    <p>buttonTitle: String -> Set's the action button title</p>    <p>buttonTextColor: UIColor -> Sets the action button title color. Default value is RGB(27,169,225).</p>    <p>buttonFont: UIFont -> Sets the action button title font. Default value is UIFont.systemFont(ofSize: 17) .</p>    <p>buttonBackgroundColor: UIColor -> Sets the background color of action button. If not set, it uses alertBackgroundColor of CDAlertView.</p>    <h2><strong>Example</strong></h2>    <p>To run the example project, clone the repo, and run pod install from the Example directory first.</p>    <h2><strong>Installation</strong></h2>    <p>CDAlertView is available through CocoaPods . To install it, simply add the following line to your Podfile:</p>    <pre>  <code class="language-objectivec">pod "CDAlertView"</code></pre>    <h2><strong>Requirements</strong></h2>    <ul>     <li>Xcode 8</li>     <li>iOS 9.0+</li>    </ul>    <h2><strong>Author</strong></h2>    <p>Candost Dagdeviren, candostdagdeviren@gmail.com</p>    <h3><strong>Icons</strong></h3>    <p>Thanks to Icons8 for beautiful icons.</p>    <h2><strong>License</strong></h2>    <p>CDAlertView is available under the MIT license. See the LICENSE file for more info.</p>    <p> </p>    <p> </p>