Yaroslav Arsenkin

2个库

ARSLineProgress

ARSLineProgress

ARSLineProgress

iOS进度条作为iOS活动指示器的替代品。此进度HUD将为您的应用程序增添一些美观的触感。此外,您可以通过自定义结构自定义此进度加载器。

| 无限 | 成功 | 失败 | 无状态动画 | | ------------------------------------- | ----------------------------------- | ----------------------------- | -------------------------------- | | ARSLineProgress 无限 | ARSLineProgress 成功 | ARSLineProgress 失败 | ARSLineProgress 无状态 |

安装

Carthage

要使用Carthage安装,请在您的Cartfile中指定此内容

github "soberman/ARSLineProgress" >= 1.0

如果您尚未安装Carthage,可以使用Homebrew进行安装

Bash $ brew update $ brew install carthage

我还建议您参考Carthage描述的该部分,以便在为iOS、tvOS或WatchOS构建时使用

CocoaPods

要使用CocoaPods安装,请将以下内容复制并粘贴到您的Podfile文件中

use_frameworks!
platform :ios, '8.0'
pod 'ARSLineProgress', '~> 1.0'

新手方式

您始终可以按照旧方式操作 - 只需将源文件拖到项目中即可。

用法

ARSLineProgress易于使用 - 您拥有ARSLineProgress类,该类提供了一系列类方法来显示进度加载器。

显示

您可以在两种模式下显示进度指示器:无限和进度。无限进度将持续显示,直到您将其隐藏。``` Swift class func show() class func showWithPresentCompetionBlock(block: () -> Void) class func showOnView(view: UIView) class func showOnView(view: UIView, completionBlock: () -> Void)

class func hide() class func hideWithCompletionBlock(block: () -> Void) ```

进度指示器将持续显示,直到NSProgress对象的fractionCompleted值为1.0,或者在没有传递原始值的情况下为100.0

``` Swift class func showWithProgressObject(progress: NSProgress) class func showWithProgressObject(progress: NSProgress, completionBlock: (() -> Void)?) class func showWithProgressObject(progress: NSProgress, onView: UIView) class func showWithProgressObject(progress: NSProgress, onView: UIView, completionBlock: (() -> Void)?)

// 更新进度 - 如您使用了上面提到的任何方法:class func updateWithProgress(value: CGFloat)

// initialValue在这些方法中的值应为0到100 class func showWithProgress(initialValue value: CGFloat) class func showWithProgress(initialValue value: CGFloat, completionBlock: (() -> Void)?) class func showWithProgress(initialValue value: CGFloat, onView: UIView) class func showWithProgress(initialValue value: CGFloat, onView: UIView, completionBlock: (() -> Void)?) ```

您可以使用这些方法仅显示“成功”勾号或失败:Swift static func showSuccess() static func showFail()

隐藏

隐藏进度HUD可以类似于您至今为止所做的那样与无限加载器一起执行,或者您可以使用这些专用方法。

Swift class func cancelPorgressWithFailAnimation(showFail: Bool) class func cancelPorgressWithFailAnimation(showFail: Bool, completionBlock: (() -> Void)?)

自定义

您可以通过提供广泛自定义的ARSLineProgressConfiguration结构来自定义progressHUD。任何更改都只有在您在显示加载器之前设置它们的情况下才会可见,否则它们将在下次显示加载器时可见。

一旦您改变主意,想要将ARSLineProgressConfiguration恢复至默认参数,请使用 static func restoreDefaults() 方法。

其他

ARSLineProgress会自动响应方向变化,因此它总是位于屏幕中央。

许可协议

ARSLineProgress遵循MIT许可证发布。请参阅LICENSE文件获取详细信息。

许可协议:MIT

  • Swift

ARSPopover

ARSPopover

适用于iPhone和iPad的通用弹出视图,您可以在项目中使用它。无需自定义绘制,无自定义元素 - 一切都是纯本地的。

| iPhone | iPad | | ---------------------------- | ------------------------ | | ARSPopover-iPhone | ARSPopover-iPad |

安装

CocoaPods

要使用CocoaPods安装,请复制以下内容并粘贴到您的.pod文件中

platform :ios, '8.3'
pod 'ARSPopover', '~> 2.0'

非CocoaPods方式

您可以始终采用旧方式 - 只需将源文件拖入您的项目中,即可开始使用。

## Usage
Sample usage of the ARSPopover might look like this:

``` objective-c
- (IBAction)showPopoverWithWebView:(id)sender {
    ARSPopover *popoverController = [ARSPopover new];
    popoverController.sourceView = self.buttonWithWebView;
    popoverController.sourceRect = CGRectMake(CGRectGetMidX(self.buttonWithWebView.bounds), CGRectGetMaxY(self.buttonWithWebView.bounds), 0, 0);
    popoverController.contentSize = CGSizeMake(400, 600);
    popoverController.arrowDirection = UIPopoverArrowDirectionUp;

    [self presentViewController:popoverController animated:YES completion:^{
        [popoverController insertContentIntoPopover:^(ARSPopover *popover, CGSize popoverPresentedSize, CGFloat popoverArrowHeight) {
            CGFloat originX = 0;
            CGFloat originY = 0;
            CGFloat width = popoverPresentedSize.width;
            CGFloat height = popoverPresentedSize.height - popoverArrowHeight;

            CGRect frame = CGRectMake(originX, originY, width, height);
            UIWebView *webView = [[UIWebView alloc] initWithFrame:frame];
            webView.scalesPageToFit = YES;
            [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]];
            [popover.view addSubview:webView];
        }];
    }];
}
```
### Required properties' configurations

In order to get a working popover, you need to specify next properties:

* `popoverController.sourceView` - The view containing the anchor rectangle for the popover.

``` objective-c
popoverController.sourceView = self.buttonWithWebView;
```

* `popoverController.sourceRect` - The rectangle in the specified view in which to anchor the popover.

``` objective-c
popoverController.sourceRect = CGRectMake(CGRectGetMidX(self.buttonWithWebView.bounds), CGRectGetMaxY(self.buttonWithWebView.bounds), 0, 0);
```

* `popoverController.contentSize` - The preferred size for the popover’s view.

``` objective-c
popoverController.contentSize = CGSizeMake(400, 600);
```

* And the last, most important thing - you have to call method `insertContentIntoPopover` and pass a block of code, which should add subviews to popover's view you wish to see.

_Be sure to call this method only after you have presented popup. Otherwise you might get wrong size in popoverPresentedSize._

``` objective-c
[popoverController insertContentIntoPopover:^(ARSPopover *popover, CGSize popoverPresentedSize, CGFloat popoverArrowHeight) {
    CGFloat originX = 0;
    CGFloat originY = 0;
    CGFloat width = popoverPresentedSize.width;
    CGFloat height = popoverPresentedSize.height - popoverArrowHeight;

    CGRect frame = CGRectMake(originX, originY, width, height);
    UIWebView *webView = [[UIWebView alloc] initWithFrame:frame];
    webView.scalesPageToFit = YES;
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]];
    [popover.view addSubview:webView];
}];
```

许可协议

ARSPopover遵循MIT许可证发布。请参阅LICENSE文件获取详细信息。

许可协议:MIT

  • Objective-C