forked from zhanxiaokai/iOS-OpenGLRenderer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPngPreviewController.m
executable file
·55 lines (49 loc) · 1.65 KB
/
PngPreviewController.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
52
53
54
55
//
// PngPreviewController.m
// OpenGLRenderer
//
// Created by apple on 2017/2/9.
// Copyright © 2017年 xiaokai.zhan. All rights reserved.
//
#import "PngPreviewController.h"
#import "PreviewView.h"
@interface PngPreviewController ()
@end
@implementation PngPreviewController
{
PreviewView* _previewView;
}
+ (id) viewControllerWithContentPath:(NSString*) pngFilePath contentFrame:(CGRect) frame;
{
return [[PngPreviewController alloc] initWithContentPath:pngFilePath
contentFrame:frame];
}
- (id) initWithContentPath:(NSString *)path
contentFrame:(CGRect)frame
{
NSAssert(path.length > 0, @"empty path");
self = [super initWithNibName:nil bundle:nil];
if (self) {
_previewView = [[PreviewView alloc] initWithFrame:frame filePath:path];
_previewView.contentMode = UIViewContentModeScaleAspectFill;
// _previewView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
self.view.backgroundColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0];
[self.view insertSubview:_previewView atIndex:0];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[_previewView render];
}
- (void) dealloc {
if(_previewView){
[_previewView destroy];
_previewView = nil;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end