jeremy 5 年 前
コミット
da8b573128

+ 264 - 0
RainbowPlanet/RainbowPlanet/Base/BaseTabbarViewController/BaseTabbarViewController 2.swift

@@ -0,0 +1,264 @@
+//
+//  BaseTabbarViewController.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/3/8.
+//  Copyright © 2019 南鑫林. All rights reserved.
+//
+
+import UIKit
+import Lottie
+import ESTabBarController_swift
+
+class BaseTabbarViewController: NSObject {
+
+    static let shared : BaseTabbarViewController = BaseTabbarViewController()
+    
+    var esTabBarController : ESTabBarController!
+    
+    /// 社区
+    var v1 : CommunityViewController!
+    /// 商城
+//    var v2 = ShoppingMallViewController!
+    /// 兑换专区
+    var v2 : RedemptionAreaViewController!
+    /// 发布
+    var v3 : BaseViewController!
+    /// 消息
+    var v4 : MessageMainViewController!
+    /// 我的
+    var v5 : UserPersonalCenterViewController!
+    
+    /// 社区
+    var lottieAnimateContentView1 : BaseLottieAnimateContentView!
+    
+    /// 商城
+    var lottieAnimateContentView2 : BaseLottieAnimateContentView!
+    
+    /// 消息
+    var lottieAnimateContentView4 : BaseLottieAnimateContentView!
+    
+    /// 我的
+    var lottieAnimateContentView5 : BaseLottieAnimateContentView!
+    
+    
+    
+    var lastIndex : Int = 0
+
+    func tabBarViewController() -> ESTabBarController {
+        esTabBarController = ESTabBarController()
+        
+        esTabBarController.tabBar.shadowImage = UIImage(named: "navbar_shadow_pic_down")
+        esTabBarController.shouldHijackHandler = {
+           [weak self] (tabbarController, viewController, index) in
+            AudioServicesPlaySystemSound(1519)
+
+            if UserModel.isTokenNil() {
+                if index == 2 || index == 3 || index == 4 {
+                    return true
+                }else {
+                    self?.reloadTabbar(index:index)
+                    self?.lastIndex = index
+                    return false
+                }
+            }else {
+                if index == 2 {
+                    self?.lastIndex = index
+                    return true
+                }else {
+                    self?.reloadTabbar(index:index)
+                    self?.lastIndex = index
+                    return false
+                }
+            }
+            
+            
+        }
+
+        esTabBarController.didHijackHandler = {
+            [weak self] tabbarController, viewController, index in
+            if UserModel.isTokenNil() {
+                kAppDelegate.setLogin()
+            }else {
+                self?.pushPublishVC()
+            }
+        }
+        
+        /// 社区
+        v1 = CommunityViewController()
+        /// 商城
+        //    var v2 = ShoppingMallViewController!
+        /// 兑换专区
+        v2 = RedemptionAreaViewController()
+        /// 发布
+        v3 = BaseViewController()
+        /// 消息
+        v4 = MessageMainViewController()
+        /// 我的
+        v5 = UserPersonalCenterViewController()
+        
+        /// 社区
+        lottieAnimateContentView1 = BaseLottieAnimateContentView(jsonStr: "communityModuleTabbar")
+        
+        /// 商城
+        lottieAnimateContentView2 = BaseLottieAnimateContentView(jsonStr: "shoppingMallModuleTabbar")
+        
+        /// 消息
+        lottieAnimateContentView4 = BaseLottieAnimateContentView(jsonStr: "messageModuleTabbar")
+        
+        /// 我的
+        lottieAnimateContentView5 = BaseLottieAnimateContentView(jsonStr: "MineModuleTabbar")
+        
+        v1.tabBarItem = ESTabBarItem.init(lottieAnimateContentView1, title: "社区", image: UIImage(named: "tabbar_home")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: nil)
+        v2.tabBarItem = ESTabBarItem.init(lottieAnimateContentView2, title: "福利", image: UIImage(named: "tabbar_shopping")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: nil)
+        v3.tabBarItem = UITabBarItem(title: nil, image: UIImage(named: "tabbar_publish")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: UIImage(named: "tabbar_publish")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal))
+        v3.tabBarItem.imageInsets =  UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0);
+        
+        if UserModel.isTokenNil() {
+            setLoginOutTabBarItem()
+        }else {
+            setLoginTabBarItem()
+        }
+
+        let n1 = BaseNavigationViewController.init(rootViewController: v1)
+        let n2 = BaseNavigationViewController.init(rootViewController: v2)
+        let n3 = BaseNavigationViewController.init(rootViewController: v3)
+        let n4 = BaseNavigationViewController.init(rootViewController: v4)
+        let n5 = BaseNavigationViewController.init(rootViewController: v5)
+
+        esTabBarController.viewControllers = [n1, n2, n3, n4, n5]
+        //将要进入前台的时候
+        setBadge()
+        NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+            if !UserModel.isTokenNil() {
+                //获取消息的小红点
+                MessageModuleManager.shared.userMemberMessageIndexApi()
+                self?.setBadge()
+            }
+
+        })
+        //监听消息
+        NotificationCenter.default.addObserver(forName: NSNotification.Name("MessageMainViewController"), object: nil, queue: OperationQueue.main) {
+            [weak self] notification in
+            self?.setBadge()
+        }
+        return esTabBarController
+    }
+    
+    func setLoginTabBarItem() {
+        v4.tabBarItem = ESTabBarItem.init(lottieAnimateContentView4, title: "消息", image: UIImage(named: "tabbar_massage")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: nil)
+        v5.tabBarItem = ESTabBarItem.init(lottieAnimateContentView5, title: "我的", image: UIImage(named: "tabbar_my")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: nil)
+    }
+    
+    func setLoginOutTabBarItem() {
+        v4.tabBarItem = ESTabBarItem.init(BaseTabBarItemContentView(), title: "消息", image: UIImage(named: "tabbar_massage")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage:nil)
+        v5.tabBarItem = ESTabBarItem.init(BaseTabBarItemContentView(), title: "我的", image: UIImage(named: "tabbar_my")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage:nil)
+    }
+    
+    /// 跳转到VC
+    func pushPublishVC() {
+        if BaseTabbarViewController.shared.v1.navigationBarbgView.isHidden {
+            let pickVc = PublishViewController()
+//            let  pickVc = PublishNewViewController()
+            let nav = BaseNavigationViewController.init(rootViewController: pickVc)
+            BaseTabbarViewController.shared.esTabBarController.present(nav, animated: true, completion: nil)
+        } else {
+            SwiftProgressHUD.shared().showText("内容上传中,请稍等", textAlignment: .center)
+        }
+    }
+    
+    // 设置Badge
+    func setBadge() {
+        //消息
+        let messageIndexModel = MessageIndexModel.shared.object()
+        if messageIndexModel?.activity?.isYes == 1 || messageIndexModel?.follow?.isYes == 1 || messageIndexModel?.notification?.isYes == 1 || messageIndexModel?.praise?.isYes == 1 || messageIndexModel?.comment?.isYes == 1 {
+            let tabBarItem = v4.tabBarItem as? ESTabBarItem
+            tabBarItem?.contentView?.badgeColor = kFE352BColor
+            tabBarItem?.contentView?.badgeValue = ""
+            tabBarItem?.contentView?.badgeOffset = UIOffset(horizontal: 0, vertical: -22)
+        }else {
+            let tabBarItem = v4.tabBarItem as? ESTabBarItem
+            tabBarItem?.contentView?.badgeValue = nil
+        }
+        
+        //我的
+        if UpdateVersionModel.shared.object()?.upGradeModelType == .update ||  UpdateVersionModel.shared.object()?.upGradeModelType == .strongUpdate {
+
+            let tabBarItem = v5.tabBarItem as? ESTabBarItem
+            tabBarItem?.contentView?.badgeColor = kFE352BColor
+            tabBarItem?.contentView?.badgeValue = ""
+            tabBarItem?.contentView?.badgeOffset = UIOffset(horizontal: 0, vertical: -22)
+        }else {
+            let tabBarItem = v5.tabBarItem as? ESTabBarItem
+            tabBarItem?.contentView?.badgeValue = nil
+        }
+    }
+    
+    func reloadTabbar(index:Int) {
+        
+        if index == 0 && lastIndex == 0  {
+            self.lottieAnimateContentView1.animationView.stop()
+            self.lottieAnimateContentView1.animationView.play()
+
+            if communityModuleTopType == .communityModuleFollowTop {
+                NotificationCenter.default.post(name: NSNotification.Name("CommunityModuleFollowTop"), object: nil)
+                
+            }
+            if communityModuleTopType == .communityModuleRecommendTop {
+//                    NotificationCenter.default.post(name: NSNotification.Name("CommunityModuleRecommendTop"), object: nil)
+                
+            }
+            if communityModuleTopType == .communityModulePlanetTop {
+                NotificationCenter.default.post(name: NSNotification.Name("CommunityModulePlanetTop"), object: nil)
+                
+            }
+            
+        }
+        if index == 1 && lastIndex == 1  {
+            self.lottieAnimateContentView2.animationView.stop()
+            self.lottieAnimateContentView2.animationView.play()
+//            NotificationCenter.default.post(name: NSNotification.Name("ShoppingMallModuleTop"), object: nil)
+            NotificationCenter.default.post(name: NSNotification.Name("RedemptionAreaModuleTop"), object: nil)
+            
+        }
+        if index == 3 && lastIndex == 3  {
+            self.lottieAnimateContentView4.animationView.stop()
+            self.lottieAnimateContentView4.animationView.play()
+            NotificationCenter.default.post(name: NSNotification.Name("MessageModuleTop"), object: nil)
+            
+        }
+        if index == 4 && lastIndex == 4  {
+            self.lottieAnimateContentView5.animationView.stop()
+            self.lottieAnimateContentView5.animationView.play()
+            NotificationCenter.default.post(name: NSNotification.Name("MineModuleTop"), object: nil)
+        }
+    }
+    
+}
+
+extension ESTabBar {
+    open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
+        
+        let view  = super.hitTest(point, with: event)
+        if view == nil {
+            if UserModel.isTokenNil() && LoginNowView.shared.loginNowView != nil {
+                for subView in subviews {
+                    if !subView.subviews.isEmpty {
+                        for subView in subView.subviews {
+                            let myPoint = subView.convert(point, from: self)
+                            if subView.bounds.contains(myPoint) {
+                                return subView
+                            }
+                        }
+                    }
+                    let myPoint = subView.convert(point, from: self)
+                    if subView.bounds.contains(myPoint) {
+                        return subView
+                    }
+                }
+            }
+        }
+        return view
+    }
+}

+ 18 - 15
RainbowPlanet/RainbowPlanet/Base/RootViewController/RootViewController.swift

@@ -13,6 +13,10 @@ import SwiftyJSON
 class RootViewController: BaseViewController {
     
     var launchOptions: [UIApplication.LaunchOptionsKey: Any]?
+    
+    deinit {
+        NXLLog("deinit")
+    }
 
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -25,21 +29,20 @@ class RootViewController: BaseViewController {
         navigationBar.isHidden = true
         view.backgroundColor = UIColor.clear
         view.addSubview(iconImageView)
-        view.addSubview(titleLabel)
+        view.addSubview(imageView)
     }
     
     override func setupLayouts() {
         
         iconImageView.snp.makeConstraints {(make) in
-            make.top.equalTo(244).multipliedBy(16/9)
-            make.width.equalTo(159)
-            make.height.equalTo(83)
+            make.bottom.equalTo(-43.5)
+
             make.centerX.equalToSuperview()
         }
         
-        titleLabel.snp.makeConstraints {(make) in
-            make.bottom.equalTo(-44)
-            make.centerX.left.right.equalToSuperview()
+        imageView.snp.makeConstraints { (make) in
+            make.top.left.right.equalToSuperview()
+            make.bottom.equalTo(iconImageView.snp.top).offset(-40)
         }
     }
     
@@ -60,7 +63,7 @@ class RootViewController: BaseViewController {
             self?.view?.ly_hideEmpty()
         }) { [weak self] loadingStatus in
             self?.iconImageView.isHidden = true
-            self?.titleLabel.isHidden = true
+            self?.iconImageView.isHidden = true
             DIYEmptyView.emptyNoDataActionView(view: self?.view,imageStr: .five,detailStr: .five,btnTitleStr: .one, btnClickBlock: { [weak self] in
                 self?.setupData()
             })
@@ -72,13 +75,13 @@ class RootViewController: BaseViewController {
         iconImageView.image = kImage(name: "default_logo")
         return iconImageView
     }()
-    lazy var titleLabel: UILabel = {
-        let titleLabel = UILabel()
-        titleLabel.text = "Copyright © 由你 版权所有"
-        titleLabel.font = kRegularFont12
-        titleLabel.textColor = k333333Color
-        titleLabel.textAlignment = .center
-        return titleLabel
+    
+    lazy var imageView: UIImageView = {
+        let imageView = UIImageView()
+        imageView.image = kImage(name: "default_image")
+        return imageView
     }()
+    
+    
 
 }

+ 196 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopViewShopInfoTableViewCell 2.swift

@@ -0,0 +1,196 @@
+//
+//  ShopViewShopInfoTableViewCell.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/5/12.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import RxSwift
+import Kingfisher
+
+class ShopViewShopInfoTableViewCell: UITableViewCell {
+    
+    let disposeBag = DisposeBag()
+    
+    typealias LookButtonClosure = (_ isSelected: Bool) -> Void
+    var lookButtonClosure : LookButtonClosure?
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ShopViewShopInfoTableViewCell {
+        let ID = "ShopViewShopInfoTableViewCell"
+        tableView.register(ShopViewShopInfoTableViewCell.self, forCellReuseIdentifier: ID)
+        let cell : ShopViewShopInfoTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ShopViewShopInfoTableViewCell
+        cell.indexPath = indexPath
+        return cell
+    }
+    
+    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+        super.init(style: style, reuseIdentifier: reuseIdentifier)
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    var indexPath: IndexPath? {
+        didSet {
+            
+        }
+    }
+    //MRAK: - 设置View
+    func setupViews() {
+        self.selectionStyle = .none
+        backgroundColor = kFFA42FColor
+        addSubview(shopIconImageView)
+        addSubview(shopNameLabel)
+        addSubview(productNumberLabel)
+        addSubview(descriptionLabel)
+        addSubview(lookButton)
+    }
+    
+    func setupLayouts() {
+        shopIconImageView.snp.makeConstraints { (make) in
+            make.top.equalTo(12)
+            make.left.equalTo(14)
+            make.size.equalTo(60)
+        }
+        shopNameLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(shopIconImageView.snp.right).offset(10)
+            make.right.equalTo(-14)
+            make.height.equalTo(14)
+            make.top.equalTo(shopIconImageView).offset(11)
+        }
+        productNumberLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(shopIconImageView.snp.right).offset(10)
+            make.right.equalTo(-14)
+            make.height.equalTo(14)
+            make.bottom.equalTo(shopIconImageView).offset(-11)
+        }
+        descriptionLabel.snp.remakeConstraints { (make) in
+            make.top.equalTo(shopIconImageView.snp.bottom).offset(10)
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.bottom.equalTo(-35)
+        }
+        lookButton.snp.makeConstraints { (make) in
+            make.top.equalTo(descriptionLabel.snp.bottom).offset(10)
+            make.right.equalTo(-18)
+            make.bottom.equalTo(-10)
+        }
+    }
+    
+    lazy var shopIconImageView: UIImageView = {
+        let shopIconImageView = UIImageView()
+        shopIconImageView.image = kImage(name: "default_pic")
+        shopIconImageView.cornerRadius = 30
+        shopIconImageView.masksToBounds = true
+        return shopIconImageView
+    }()
+    
+    lazy var shopNameLabel: UILabel = {
+        let shopNameLabel = UILabel()
+        shopNameLabel.text = "彩虹星球专营店"
+        shopNameLabel.textColor = UIColor.white
+        shopNameLabel.font = kMediumFont15
+        return shopNameLabel
+    }()
+    
+    lazy var productNumberLabel: UILabel = {
+        let productNumberLabel = UILabel()
+        productNumberLabel.text = "全部商品:200"
+        productNumberLabel.textColor = UIColor.white
+        productNumberLabel.font = kRegularFont14
+        return productNumberLabel
+    }()
+    
+    lazy var descriptionLabel: UILabel = {
+        let descriptionLabel = UILabel()
+        descriptionLabel.textColor = UIColor.white
+        descriptionLabel.font = kRegularFont14
+        descriptionLabel.numberOfLines = 0
+        descriptionLabel.sizeToFit()
+        return descriptionLabel
+    }()
+    
+    lazy var lookButton: UIButton = {
+        let lookButton = UIButton(type: UIButton.ButtonType.custom)
+        lookButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
+        lookButton.titleLabel?.font = kRegularFont14
+        lookButton.isHidden = true
+        lookButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            self?.lookButton.isSelected = !(self?.lookButton.isSelected)!
+            if let lookButtonClosure = self?.lookButtonClosure {
+                lookButtonClosure(lookButton.isSelected)
+            }
+        }).disposed(by: disposeBag)
+        return lookButton
+    }()
+    
+    var shopModel : ShopModel? {
+        didSet {
+            
+            let str = shopModel?.shopDesc
+            let attributeString = NSMutableAttributedString(string:str ?? "")
+            attributeString.changeAllLineSpacing(2)
+            descriptionLabel.attributedText = attributeString
+            
+            
+            let dict = [
+                NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14),
+            ]
+            let height: CGFloat = str?.boundingRect(with: CGSize(width: kScreenWidth-60-28-10, height:CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: dict, context: nil).size.height ?? 0
+            let labelHeight = height
+            
+            let count = Int((labelHeight) / descriptionLabel.font.lineHeight)
+
+            
+            if (shopModel?.isOpen ?? false) {
+                descriptionLabel.numberOfLines = 0
+                descriptionLabel.lineBreakMode = .byCharWrapping
+                lookButton.isSelected = true
+                lookButton.setImage(UIImage.init(named: "common_word_packup"), for: UIControl.State.selected)
+                lookButton.setTitle("收起", for: UIControl.State.normal)
+            } else {
+                descriptionLabel.numberOfLines = 2
+                descriptionLabel.lineBreakMode = .byTruncatingTail
+                lookButton.isSelected = false
+                lookButton.setImage(kImage(name: "common_word_unfold"), for: UIControl.State.normal)
+                lookButton.setTitle("查看更多", for: UIControl.State.normal)
+            }
+            lookButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.right, imageTitleSpace: 4)
+
+            
+            shopIconImageView.kf.setImage(with: kURLImage(name: shopModel?.logoImg ?? "default_pic"), placeholder: kImage(name: "default_pic"))
+            //KingfisherManager.shared.cache.clearMemoryCache()
+             shopNameLabel.text = shopModel?.shopName
+
+            
+            if count > 2 {
+                descriptionLabel.snp.remakeConstraints { (make) in
+                    make.top.equalTo(shopIconImageView.snp.bottom).offset(10)
+                    make.left.equalTo(14)
+                    make.right.equalTo(-14)
+                    make.bottom.equalTo(-35)
+                }
+                lookButton.isHidden = false
+            }else {
+                descriptionLabel.snp.remakeConstraints { (make) in
+                    make.top.equalTo(shopIconImageView.snp.bottom).offset(10)
+                    make.left.equalTo(14)
+                    make.right.equalTo(-14)
+                    make.bottom.equalTo(-10)
+                }
+                lookButton.isHidden = true
+            }
+            
+        }
+    }
+    
+    var paginationModel: PaginationModel? {
+        didSet{
+            productNumberLabel.text = "全部商品:\(paginationModel?.total ?? 0)"
+        }
+    }
+}

+ 22 - 0
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/default_image.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "default_image@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "default_image@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/default_image.imageset/default_image@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/default_image.imageset/default_image@3x.png


+ 1 - 0
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/default_logo.imageset/Contents.json

@@ -11,6 +11,7 @@
     },
     {
       "idiom" : "universal",
+      "filename" : "default_logo@3x.png",
       "scale" : "3x"
     }
   ],

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/default_logo.imageset/default_logo@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/default_logo.imageset/default_logo@3x.png


+ 15 - 18
RainbowPlanet/RainbowPlanet/Supporting Files/Launch Screen.storyboard

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
-    <device id="retina6_1" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -15,29 +13,27 @@
             <objects>
                 <viewController id="01J-lp-oVM" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
-                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Copyright © 由你 版权所有" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
-                                <rect key="frame" x="0.0" y="837.5" width="414" height="14.5"/>
-                                <fontDescription key="fontDescription" type="system" pointSize="12"/>
-                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                                <nil key="highlightedColor"/>
-                            </label>
                             <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="default_logo" translatesAutoresizingMaskIntoConstraints="NO" id="xvS-ua-mvp">
-                                <rect key="frame" x="127.5" y="244" width="159" height="83"/>
+                                <rect key="frame" x="108" y="540.5" width="159" height="83"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="159" id="Vfh-8p-ezm"/>
                                     <constraint firstAttribute="height" constant="83" id="ZXR-zb-Khl"/>
                                 </constraints>
                             </imageView>
+                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="default_image" translatesAutoresizingMaskIntoConstraints="NO" id="Xs9-Fh-gue">
+                                <rect key="frame" x="0.0" y="0.0" width="375" height="500.5"/>
+                            </imageView>
                         </subviews>
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <constraints>
-                            <constraint firstItem="NPT-cs-gRi" firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
-                            <constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="NPT-cs-gRi" secondAttribute="leading" symbolic="YES" id="SfN-ll-jLj"/>
-                            <constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="44" id="Y44-ml-fuU"/>
-                            <constraint firstItem="xvS-ua-mvp" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" multiplier="16/9" constant="244" id="Zfa-KX-qFG"/>
+                            <constraint firstItem="xvS-ua-mvp" firstAttribute="top" secondItem="Xs9-Fh-gue" secondAttribute="bottom" constant="40" id="FKu-ve-VzX"/>
+                            <constraint firstItem="Xs9-Fh-gue" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="JQM-q6-83l"/>
+                            <constraint firstAttribute="bottom" secondItem="xvS-ua-mvp" secondAttribute="bottom" constant="43.5" id="LVc-ds-8um"/>
+                            <constraint firstItem="NPT-cs-gRi" firstAttribute="trailing" secondItem="Xs9-Fh-gue" secondAttribute="trailing" id="Wef-6o-DY0"/>
+                            <constraint firstItem="Xs9-Fh-gue" firstAttribute="leading" secondItem="NPT-cs-gRi" secondAttribute="leading" id="opp-10-bCJ"/>
                             <constraint firstItem="xvS-ua-mvp" firstAttribute="centerX" secondItem="NPT-cs-gRi" secondAttribute="centerX" id="sS8-sQ-56x"/>
                         </constraints>
                         <viewLayoutGuide key="safeArea" id="NPT-cs-gRi"/>
@@ -49,6 +45,7 @@
         </scene>
     </scenes>
     <resources>
-        <image name="default_logo" width="159" height="83"/>
+        <image name="default_image" width="375" height="500"/>
+        <image name="default_logo" width="158" height="83"/>
     </resources>
 </document>

+ 82 - 0
RainbowPlanet/RainbowPlanet/Tools/Extension/Extension+UIAlertController 2.swift

@@ -0,0 +1,82 @@
+//
+//  Extension+UIAlertController.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2018/9/13.
+//  Copyright © 2018年 南鑫林. All rights reserved.
+//
+
+import UIKit
+
+extension UIAlertController {
+    /// 在指定视图控制器上弹出普通消息提示框2消失
+    static func showAlert(title: String, in viewController: UIViewController) {
+        let alert = UIAlertController(title: title, message: nil, preferredStyle: .alert)
+        viewController.present(alert, animated: true)
+        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2) {
+            viewController.presentedViewController?.dismiss(animated: false, completion: nil)
+        }
+    }
+    
+    ///在根视图控制器上弹出普通消息提示框2s消失
+    static func showAlert(title: String) {
+        if let vc = UIApplication.shared.keyWindow?.rootViewController {
+            showAlert(title: title, in: vc)
+        }
+    }
+    
+    ///在指定视图控制器上弹出普通消息提示框
+    static func showAlert(message: String, in viewController: UIViewController) {
+        let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
+        alert.addAction(UIAlertAction(title: "确定", style: .cancel))
+        viewController.present(alert, animated: true)
+    }
+    
+    ///在根视图控制器上弹出普通消息提示框
+    static func showAlert(message: String) {
+        if let vc = UIApplication.shared.keyWindow?.rootViewController {
+            showAlert(message: message, in: vc)
+        }
+    }
+    
+    ///在指定视图控制器上弹出确认框
+    static func showConfirm(title:String? = nil, message: String, in viewController: UIViewController,
+                            confirm: ((UIAlertAction)->Void)?) {
+        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
+        alert.addAction(UIAlertAction(title: "取消", style: .cancel))
+        alert.addAction(UIAlertAction(title: "确定", style: .default, handler: confirm))
+        viewController.present(alert, animated: true)
+    }
+
+
+    
+    ///在根视图控制器上弹出确认框
+    static func showConfirm(title:String? = nil, message: String, confirm: ((UIAlertAction)->Void)?) {
+        if let vc = UIApplication.shared.keyWindow?.rootViewController {
+            showConfirm(title:title,message: message, in: vc, confirm: confirm)
+        }
+    }
+
+
+    /// 调用相机相册
+    ///
+    /// - Parameters:
+    ///   - camera: 相机
+    ///   - album: 相册
+    static func showConfirmActionSheet(camera: ((UIAlertAction)->Void)?,album: ((UIAlertAction)->Void)?) {
+        let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
+        let cancelAction = UIAlertAction(title: "取消", style: .cancel)
+        cancelAction.setValue(kThemeColor, forKey: "titleTextColor")
+        alert.addAction(cancelAction)
+
+        let cameraAction = UIAlertAction(title: "拍照", style: .default, handler: camera)
+        cameraAction.setValue(kThemeColor, forKey: "titleTextColor")
+        alert.addAction(cameraAction)
+
+        let albumAction = UIAlertAction(title: "从手机相册选取", style: .default, handler: album)
+        albumAction.setValue(kThemeColor, forKey: "titleTextColor")
+        alert.addAction(albumAction)
+
+        UIViewController.topMost?.present(alert, animated: true)
+    }
+}