iOS_UI_表单——第三方_16XLActionController-tweetbot-youtube


请添加图片描述

请添加图片描述

platform :ios, '9.0'
use_frameworks!

target 'DemoApp' do
    source 'https://github.com/CocoaPods/Specs.git'
    pod 'XLActionController'
    pod 'XLActionController/Periscope'
    pod 'XLActionController/Skype'
    pod 'XLActionController/Spotify'
    pod 'XLActionController/Tweetbot'
    pod 'XLActionController/Twitter'
    pod 'XLActionController/Youtube'
end

0. 测试UI

import UIKit
import XLActionController //
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Test UI:
        let button = UIButton(frame: CGRect(x: 20, y: 300, width: 374, height: 40))
        button.backgroundColor = UIColor.orange
        button.titleLabel?.font = .systemFont(ofSize: 24)
        button.setTitle("Show me the XLActionController", for: .normal)
        button.addTarget(self, action: #selector(yeBtn),
                         for: .touchUpInside)
        self.view.addSubview(button)
        self.view.backgroundColor = UIColor.orange
    }
    
    // 6种 风格的 表单:
    @objc func yeBtn(){
        //yeTye1TweetbotActionController()
        //yeTye2TwitterActionController()
        //yeTye3YoutubeActionController()
        //yeTye4periscopeActionController()
        //yeTye5spotifyActionController()
        yeTye6skypeActionController()
    }
}

1. 风格一

func yeTye1TweetbotActionController(){
    // 初始化一个表单:
    let actionController = TweetbotActionController()
    
    // 添加 表单选项:
    // 在表单中添加一个选项: 设置样式:默认,
    actionController.addAction(Action("View Details", style: .default, handler: { action in
        print("---点击了该Btn,表单消失后才执行此闭包,View Details--")
    }))
    actionController.addAction(Action("View Retweets", style: .default, handler: { action in
        print("View Retweets")
    }))
    actionController.addAction(Action("View in Favstar", style: .default, handler: { action in
        print("View in Favstar")
    }))
    
    //
    actionController.addAction(Action("Translate", style: .default, executeImmediatelyOnTouch: true, handler: { action in
        print("---被点击后,立即执行此闭包,(不用等表单消失),View Translate--")
    }))
    
    // 添加一个段落:
    actionController.addSection(Section())
    
    // 在 新段落中添加一个 选项, 样式为: 取消 (用于关闭表单)
    actionController.addAction(Action("Cancel", style: .cancel, handler:nil))
    
    // 模态推出 表单:
    present(actionController, animated: true, completion: nil)
}

2. 风格二

func yeTye2TwitterActionController() {
    let actionSheet = TwitterActionController()
    
    // 设置 表单头部的标题
    actionSheet.headerData = "Accounts"
    
    // 添加选项,默认样式,设置标题,子标题,自定义左侧图标及交互动作:
    actionSheet.addAction(Action(ActionData(title: "Xmartlabs", subtitle: "@xmartlabs", image: UIImage(named: "tw-xmartlabs")!), style: .default, handler: { action in
        print("@xmartlabs")
    }))
    actionSheet.addAction(Action(ActionData(title: "Miguel", subtitle: "@remer88", image: UIImage(named: "tw-remer")!), style: .default, handler: { action in
        print("@remer88")
    }))
    
    // 模态推出表单:
    present(actionSheet, animated: true, completion: nil)
}

3. 风格三

func yeTye3YoutubeActionController(){
    let actionController = YoutubeActionController()
    
    // 添加选项,默认样式,设置标题,子标题,自定义左侧图标及交互动作:
    actionController.addAction(Action(ActionData(title: "Add to Watch Later", image: UIImage(named: "yt-add-to-watch-later-icon")!), style: .default, handler: { action in
    }))
    actionController.addAction(Action(ActionData(title: "Add to Playlist...", image: UIImage(named: "yt-add-to-playlist-icon")!), style: .default, handler: { action in
    }))
    actionController.addAction(Action(ActionData(title: "Share...", image: UIImage(named: "yt-share-icon")!), style: .default, handler: { action in
    }))
    
    // 样式: 取消
    actionController.addAction(Action(ActionData(title: "Cancel", image: UIImage(named: "yt-cancel-icon")!), style: .cancel, handler: nil))
    
    present(actionController, animated: true, completion: nil)
}

4. 风格四

func yeTye4periscopeActionController(){
    let actionController = PeriscopeActionController()
    // 设置 表单头部的标题
    actionController.headerData = "Are you sure you want to block?"
    
    // 添加 选项: 样式: .destructive破坏;
    actionController.addAction(Action("Block user", style: .destructive, handler: { action in
    }))
    
    // 添加一个段落:(段落的风格为和上面一样的PeriscopeSection)
    actionController.addSection(PeriscopeSection())
    actionController.addAction(Action("Cancel", style: .cancel, handler: { action in
    }))
    
    present(actionController, animated: true, completion: nil)
}

5. 风格五

func yeTye5spotifyActionController(){
    let actionController = SpotifyActionController()
    
    // 设置 表单头部的标题,子标题 和 自定义左侧图标:
    actionController.headerData = SpotifyHeaderData(title: "The Fast And The Furious Soundtrack Collection", subtitle: "Various Artists", image: UIImage(named: "sp-header-icon")!)
    
    // 添加选项: 设置标题,左侧图标,样式及交互事件:
    actionController.addAction(Action(ActionData(title: "Save Full Album", image: UIImage(named: "sp-add-icon")!), style: .default, handler: { action in }))
    actionController.addAction(Action(ActionData(title: "Remove", image: UIImage(named: "sp-remove-icon")!), style: .default, handler: { action in }))
    actionController.addAction(Action(ActionData(title: "Share", image: UIImage(named: "sp-share-icon")!), style: .default, handler: { action in }))
    actionController.addAction(Action(ActionData(title: "Go to Album", image: UIImage(named: "sp-view-album-icon")!), style: .default, handler: { action in }))
    actionController.addAction(Action(ActionData(title: "Start radio", image: UIImage(named: "sp-radio-icon")!), style: .default, handler: { action in }))
    
    present(actionController, animated: true, completion: nil)
}

6. 风格六


func yeTye6skypeActionController(){
    let actionController = SkypeActionController()
    actionController.addAction(Action("Take photo", style: .default, handler: { action in
    }))
    actionController.addAction(Action("Choose existing photo", style: .default, handler: { action in
    }))
    actionController.addAction(Action("Remove profile picture", style: .default, handler: { action in
    }))
    actionController.addAction(Action("Cancel", style: .cancel, handler: nil))
    
    present(actionController, animated: true, completion: nil)
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值