Skip to content

Commit

Permalink
Close button README
Browse files Browse the repository at this point in the history
* Bump version
* Fixes #79
  • Loading branch information
JanGorman committed Jul 8, 2018
1 parent 9feba49 commit dc02447
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Agrume.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Agrume"
s.version = "5.0.3"
s.version = "5.1.0"
s.summary = "An iOS image viewer written in Swift."
s.swift_version = "4.1"

Expand Down
3 changes: 2 additions & 1 deletion Agrume/AgrumeOverlayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ final class AgrumeOverlayView: UIView {
}()

private lazy var navigationItem = UINavigationItem(title: "")
private lazy var defaultCloseButton = UIBarButtonItem(title: "Close", style: .plain, target: self, action: #selector(close))
private lazy var defaultCloseButton = UIBarButtonItem(title: NSLocalizedString("Close", comment: "Close image view"),
style: .plain, target: self, action: #selector(close))

init(closeButton: UIBarButtonItem?) {
super.init(frame: .zero)
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ let agrume = Agrume(images: images)

Remote animated gifs (i.e. using the url or urls initializer) are supported. Agrume does the image type detection and displays them properly. If using Agrume from a custom `UIImageView` you may need to rebuild the `UIImage` using the original data to preserve animation vs. using the `UIImage` instance from the image view.

### Close Button

Per default you dismiss the zoomed view by dragging/flicking the image off screen. You can opt out of this behaviour and instead display a close button. To match the look and feel of your app you can pass in a custom `UIBarButtonItem`:

```swift

// Default button that displays NSLocalizedString("Close", …)
let agrume = Agrume(image: UIImage(named: "")!, .dismissal: .withButton(nil))
// Customise the button any way you like. For example display a system "x" button
let button = UIBarButtonItem(barButtonSystemItem: .stop, target: nil, action: nil)
button.tintColor = .red
let agrume = Agrume(image: UIImage(named: "")!, .dismissal: .withButton(button))

```

The included sample app shows both cases for reference.

### Custom Download Handler

If you want to take control of downloading images (e.g. for caching), you can also set a download closure that calls back to Agrume to set the image. For example, let's use [MapleBacon](https://github.com/JanGorman/MapleBacon).
Expand Down

0 comments on commit dc02447

Please sign in to comment.