Permalink
Browse files

set image by different means

  • Loading branch information...
wang9262 committed Mar 18, 2018
1 parent c397c6d commit f2f7cfc979e13fc42e4dc2dd51631c4ce94e9861
@@ -14,7 +14,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Pod1: b46f1625f8d28360247b82d755b373973e44ca12
Pod2: 7903cf8c0b291c730cc4093f3dbd29cd983e3968
Pod2: d27f45afe898b078361d789de907b3391c942d00
PODFILE CHECKSUM: be48c43edfac071578773fbd3644b9cedec5a21f

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -22,6 +22,7 @@
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; };
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
91BAF6BFDD73BDBF0A6A15FD /* libPods-ResourceDemo_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 531118E282E04828026D81E8 /* libPods-ResourceDemo_Tests.a */; };
E306B4AA205E4303004DC0F2 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E306B4A9205E4303004DC0F2 /* Images.xcassets */; };
FF27AC2CE646FAF9908386E1 /* libPods-ResourceDemo_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5381A5C21BECC79CB620FA88 /* libPods-ResourceDemo_Example.a */; };
/* End PBXBuildFile section */
@@ -65,7 +66,7 @@
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
94178BF11F6DE84AEA66DFE9 /* Pods-ResourceDemo_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ResourceDemo_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ResourceDemo_Tests/Pods-ResourceDemo_Tests.release.xcconfig"; sourceTree = "<group>"; };
CB315FBDEEB0098EFD1D65CE /* Pods-ResourceDemo_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ResourceDemo_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ResourceDemo_Tests/Pods-ResourceDemo_Tests.debug.xcconfig"; sourceTree = "<group>"; };
E3827693205E325200FA240B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = "/Users/zj-db0370/Develop/TestDemos/ResourceDemo/Example/ResourceDemo/Images.xcassets"; sourceTree = "<absolute>"; };
E306B4A9205E4303004DC0F2 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -136,8 +137,8 @@
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */,
6003F5A5195388D20070C39A /* VVLViewController.h */,
6003F5A6195388D20070C39A /* VVLViewController.m */,
E3827693205E325200FA240B /* Images.xcassets */,
71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */,
E306B4A9205E4303004DC0F2 /* Images.xcassets */,
6003F594195388D20070C39A /* Supporting Files */,
);
name = "Example for ResourceDemo";
@@ -282,6 +283,7 @@
buildActionMask = 2147483647;
files = (
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */,
E306B4AA205E4303004DC0F2 /* Images.xcassets in Resources */,
71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */,
6003F598195388D20070C39A /* InfoPlist.strings in Resources */,
);
@@ -7,6 +7,7 @@
//
#import "VVLViewController.h"
#import <Pod1Object.h>
#import <Pod2Object.h>
@interface VVLViewController ()
@@ -21,6 +22,14 @@ @implementation VVLViewController
- (void)viewDidLoad {
[super viewDidLoad];
Pod1Object *pod1 = [Pod1Object new];
Pod2Object *pod2 = [Pod2Object new];
// Pod1
self.topImageView.image = pod1.podImage;
// Main
self.centerImageView.image = [UIImage imageNamed:@"Pod"];
// Pod2
self.bottomImageView.image = pod2.podImage;
}
- (void)didReceiveMemoryWarning {
@@ -0,0 +1,14 @@
//
// NSBundle+Pod1Bundle.h
// Pods
//
// Created by Vong on 2018/3/18.
//
#import <Foundation/Foundation.h>
@interface NSBundle (Pod1Bundle)
+ (NSBundle *)pod1_bundle;
@end
@@ -0,0 +1,24 @@
//
// NSBundle+Pod1Bundle.m
// Pods
//
// Created by Vong on 2018/3/18.
//
#import "NSBundle+Pod1Bundle.h"
// FakeClass 仅作占位符用,即只为分类中的 `bundleForClass:` 方法服务
@interface Pod1FakeClass : NSObject
@end
@implementation Pod1FakeClass
@end
@implementation NSBundle (Pod1Bundle)
+ (NSBundle *)pod1_bundle {
NSBundle *bundle = [self bundleForClass:[Pod1FakeClass class]];
NSURL *url = [bundle URLForResource:@"Pod1" withExtension:@"bundle"];
return [self bundleWithURL:url];
}
@end
@@ -9,4 +9,6 @@
@interface Pod1Object : NSObject
@property (nonatomic, strong) UIImage *podImage;
@end
@@ -6,12 +6,15 @@
//
#import "Pod1Object.h"
#import "NSBundle+Pod1Bundle.h"
@implementation Pod1Object
- (instancetype)init {
if (self = [super init]) {
_podImage = [UIImage imageNamed:@"Pod"
inBundle:[NSBundle pod1_bundle]
compatibleWithTraitCollection:nil];
}
return self;
}
@@ -9,4 +9,6 @@
@interface Pod2Object : NSObject
@property (nonatomic, strong) UIImage *podImage;
@end
@@ -11,7 +11,9 @@ @implementation Pod2Object
- (instancetype)init {
if (self = [super init]) {
_podImage = [UIImage imageNamed:@"Pod"
inBundle:[NSBundle bundleForClass:[self class]]
compatibleWithTraitCollection:nil];
}
return self;
}

0 comments on commit f2f7cfc

Please sign in to comment.