Skip to content

Commit

Permalink
Support for changing indicator color
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin49999 committed Dec 11, 2017
1 parent dcfaa23 commit 9afafee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ActivityIndicatingNavigationItem.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ActivityIndicatingNavigationItem"
s.version = "1.0.3"
s.version = "1.0.4"
s.summary = "UINavigationItem subclass that indicates activity with UIActivityIndicator for right/left bar items"
s.description = "Use to easily animate the right or left bar button item with this UINavigationItem subclass. Now a common UI practice in iOS for indicating activity while saving data in edit profile screens, etc."
s.homepage = "https://github.com/longhorn499/ActivityIndicatingNavigationItem"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="dGZ-Ol-am8">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="dGZ-Ol-am8">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ Stop animating:
activityIndicatingNavigationItem.stopAnimating(.right)
```

Changing the style (default style is `gray`):

## Configuration

Changing the activity indicator style (default style is `gray`):

````swift
activityIndicatingNavigationItem.indicatorStyle = .white
````

Changing the activity indicator color (can also update in Storyboard):

````swift
activityIndicatingNavigationItem.indicatorColor = .blue
````

## Requirements

Expand Down
7 changes: 6 additions & 1 deletion Source/ActivityIndicatingNavigationItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public final class ActivityIndicatingNavigationItem: UINavigationItem {
// MARK: Public Variables

public var indicatorStyle: UIActivityIndicatorViewStyle! = .gray

@IBInspectable public var indicatorColor: UIColor?

// MARK: Private Variables

private var initialRightBarButtonItem: UIBarButtonItem?
Expand Down Expand Up @@ -81,6 +82,8 @@ public final class ActivityIndicatingNavigationItem: UINavigationItem {
rightBarButtonItem = nil

let activityIndicator = UIActivityIndicatorView.init(activityIndicatorStyle: indicatorStyle)
activityIndicator.color = indicatorColor

rightActivityIndicator = activityIndicator
rightBarButtonItem = UIBarButtonItem.init(customView: activityIndicator)
rightActivityIndicator?.startAnimating()
Expand All @@ -97,6 +100,8 @@ public final class ActivityIndicatingNavigationItem: UINavigationItem {
leftBarButtonItem = nil

let activityIndicator = UIActivityIndicatorView.init(activityIndicatorStyle: indicatorStyle)
activityIndicator.color = indicatorColor

leftActivityIndicator = activityIndicator
leftBarButtonItem = UIBarButtonItem.init(customView: activityIndicator)
leftActivityIndicator?.startAnimating()
Expand Down

0 comments on commit 9afafee

Please sign in to comment.