KLFUserInterfaceGuide 0.1.1

KLFUserInterfaceGuide 0.1.1

farhad jebelli维护。



KLFUserInterfaceGuide

CI Status Version License Platform

描述

一个轻量级、易于使用的iOS库,可以让用户熟悉您的应用程序。它需要一个视图和一个文本(可选的一个标记,这样您就不必担心展示方式了),它使用标记在User Defaults上设置一个标志。您可以在多次展示后再次展示,因为它具有队列机制,您不会收到UIViewController展示错误。

安装

KLFUserInterfaceGuide通过CocoaPods提供。要安装它,只需在您的Podfile中添加以下行

pod 'KLFUserInterfaceGuide'

用法

import KLFUserInterfaceGuide

在您的viewController中调用presentUserInterfaceGuide函数

最简单的方法

// view: The view you are going to show guide for
// message: The message to show also can be `NSAttributedString`
presentUserInterfaceGuide(view: self.subview, message: "This is very beginning message!!!")

还提供了一些展示选项

// tag: will force the guide to show once not providing tag will present the guide every time
// dismissWhenTapedOutside: default behavior forces user to tap inside the box set this property to true so the guide will dismiss by tapping outside.
// decision: is '(CGPoint) -> Bool' closure passes the touchpoint of user in coordinate of view if return true means touchpoints is where it should be and guide will dismiss if false noting happens
// completion: will call after the completion of `UIViewController.dismiss()` called 

self.presentUserInterfaceGuide(view: subView, message: "This is very begining message!!!", tag: "view1", dismissWhenTapedOutside: true,
decision: { point in
    if self.subView.frame.contains(point) {
        self.subviewTapped()
        return true
    }
    return false
}, completion: {
     subViewTapped()
})

配置

您可以在任何地方设置配置,但最佳位置是 AppDelegate 中的 didFinishLaunchingWithOptions

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    var config = KLFUserInterfaceGuide.config

    //alpa of background of the guide
    config.alpha = 0.8
    //color of background of the guide
    config.background = .blue
    //margin of the box over the view
    config.rectMargin = 10
    //radius  of the box over the view
    config.rectRadius = 10
    //font of the message
    config.font = UIFont.systemFont(ofSize: 14)
    //alignment of the message
    config.textAlignment = .natural
    // bubble background
    config.bubbleBackgroundColor = .gray
    // bubble border
    config.bubbleBorderColor = .yellow
    // bubble message text
    config.bubbleTextColor = .cyan
    
    KLFUserInterfaceGuide.config = config
}

作者

[email protected], [email protected]

许可

KLFUserInterfaceGuide 在 MIT 许可下提供。更多信息请参阅 LICENSE 文件。