-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathFirstViewController.m
51 lines (40 loc) · 1.57 KB
/
FirstViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// FirstViewController.m
// BFRImageViewer
//
// Created by Andrew Yates on 20/11/2015.
// Copyright © 2015 Andrew Yates. All rights reserved.
//
#import "FirstViewController.h"
@import BFRImageViewer;
@interface FirstViewController ()
@property (strong, nonatomic) NSURL *imgURL;
@end
@implementation FirstViewController
- (instancetype) init {
if (self = [super init]) {
self.title = @"Single GIF";
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self addImageButtonToView];
self.imgURL = [NSURL URLWithString:@"https://media0.giphy.com/media/huJmPXfeir5JlpPAx0/200.gif"];
}
- (void)openImage {
//Here, the image source could be an array containing/a mix of URL strings, NSURLs, PHAssets, or UIImages
BFRImageViewController *imageVC = [[BFRImageViewController alloc] initWithImageSource:@[self.imgURL]];
[self presentViewController:imageVC animated:YES completion:nil];
}
#pragma mark - Misc
- (void)addImageButtonToView {
UIButton *openImageFromURL = [UIButton buttonWithType:UIButtonTypeRoundedRect];
openImageFromURL.translatesAutoresizingMaskIntoConstraints = NO;
[openImageFromURL setTitle:@"Open Image" forState:UIControlStateNormal];
[openImageFromURL addTarget:self action:@selector(openImage) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:openImageFromURL];
[openImageFromURL.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = YES;
[openImageFromURL.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor].active = YES;
}
@end