PAGestureAssistant 0.2.10

PAGestureAssistant 0.2.10

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后更新2016年6月

Pedro Almeida 维护。




Possibilities iPad multi-window

PAGestureAssistant 是一个易于使用的 UIViewController 分类,用于向用户展示交互提示和教程,预设了便捷的手势,也允许自定义。

行为

此库有两个不同的行为:

助手模式

适用于非显而易见的用法模式,如向下滑动来消失视图。

每次用户闲置时间超过定义的间隔时,动画开始,用户交互会传递到下面的视图。为了实现此行为,使用任何 不带完成块的 showGestureAssistant 方法。

教程模式

适用于教授用户复杂流程。

定义的间隔后,动画只会显示一次,且任何用户交互都会被阻塞。为了实现此行为,只需向任何 showGestureAssistant 方法传递一个 完成块(即使是空的一个)。

使用方法

要运行示例项目,首先将仓库克隆,然后从 Example 目录运行 pod install

然后,在 viewDidAppear 中设置您的助手。强烈建议不要在之前调用它!

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // Shows a tap gesture animation in the view's center
    // everytime the user idles for more than 5 seconds.
    [self showGestureAssistantForTap:PAGestureAssistantTapSingle
                                view:self.view
                                text:@"Tap here to begin"
                   afterIdleInterval:5];
}

就是这样!

您可以从下面的列表中选择预定义动画,也可以使用 startPointendPoint (检查下面的教程示例)定义自己的自定义滑动。

// Tap animations
PAGestureAssistantTapSingle
PAGestureAssistantTapLongPress
PAGestureAssistantTapDouble

// Swipe animations
PAGestureAssistantSwipeDirectonUp
PAGestureAssistantSwipeDirectonDown
PAGestureAssistantSwipeDirectonLeft
PAGestureAssistantSwipeDirectonRight

您也可以随时禁用助手(但实际上不应需要)。

- (void)stopGestureAssistant;
- (void)stopGestureAssistantWithCompletion:(PAGestureCompletion)completion;

外观

您可以自定义以下属性,或使用 NSAttributedString 按您希望的格式设置文本。

/* Sets a custom overlay color */
[[PAGestureAssistant appearance] setBackgroundColor:[UIColor colorWithWhite:1 alpha:0.8f]];

/* Sets a custom text color */
[[PAGestureAssistant appearance] setTextColor:[UIColor darkGrayColor]];

/* Sets the gesture view color */
[[PAGestureAssistant appearance] setTapColor:self.view.tintColor];

/* Sets a custom image for the gesture view */
[[PAGestureAssistant appearance] setTapImage:[UIImage imageNamed:@"imageName"]];

示例

教程示例

/* Chain multiple calls to achieve a tutorial effect */

// First show a custom swipe...
[self showGestureAssistantForSwipeWithStartPoint:CGPointMake(60, 60)
                                        endPoint:self.view.center
                                            text:@"This is a custom swipe"
                               afterIdleInterval:0
                                      completion:^(BOOL finished) {

    // ...then a tap on a button...
    [self showGestureAssistantForTap:PAGestureAssistantTapSingle
                                view:self.button
                                text:@"This is a single tap"
                   afterIdleInterval:0
                          completion:^(BOOL finished) {

        // ...and a swipe up gesture
        [self showGestureAssistantForSwipeDirection:PAGestureAssistantSwipeDirectonUp
                                               text:@"This is a swipe up"
                                  afterIdleInterval:0
                                         completion:^(BOOL finished) {

                                              // do something
                                              NSLog(@"Tutorial complete");

        }];
    }];
}];

需求

  • iOS 7.0+
  • 如果您手动安装,还必须复制 FrameAccessor

安装

PAGestureAssistant可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中即可:

pod "PAGestureAssistant"

作者

佩德罗·阿尔梅达,@ipedro

致谢

手图标由Zach Blevins设计。分类实现受到了Bryce Buchanan的swizzling方法的启发。

许可证

PAGestureAssistant遵循MIT许可证。

版权所有(c)2016佩德罗·阿尔梅达。

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.