diff --git a/Classes/View/PDFKBasicPDFViewer.h b/Classes/View/PDFKBasicPDFViewer.h index a1076ec..51133a8 100644 --- a/Classes/View/PDFKBasicPDFViewer.h +++ b/Classes/View/PDFKBasicPDFViewer.h @@ -15,6 +15,9 @@ #import @class PDFKDocument; +@class PDFKPageScrubber; +@class PDFKBasicPDFViewerSinglePageCollectionView; +@class PDFKBasicPDFViewerThumbsCollectionView; typedef void (^PDFKBasicPDFViewerPageChangeBlock)(NSUInteger page); @@ -81,5 +84,54 @@ typedef void (^PDFKBasicPDFViewerPageChangeBlock)(NSUInteger page); */ @property (nonatomic, assign) BOOL standalone; +/** + The toolbar displaied at the top of the screen. + */ +@property (nonatomic, retain, readonly) UIToolbar *navigationToolbar; +/** + The slider at the bottom of the screen to show the thumbnails. + */ +@property (nonatomic, retain, readonly) UIToolbar *thumbnailSlider; +/** + The popover controller to share the document on the iPad. + */ +@property (nonatomic, strong, readonly) UIPopoverController *activityPopoverController; +/** + The share button. + */ +@property (nonatomic, strong, readonly) UIBarButtonItem *shareItem; +/** + The item that notes wether or not the page is bookmarked. + */ +@property (nonatomic, strong, readonly) UIBarButtonItem *bookmarkItem; +/** + The page scrubber at the bottom of the view. + */ +@property (nonatomic, strong, readonly) PDFKPageScrubber *pageScrubber; +/** + The collection view of single pages to display. + */ +@property (nonatomic, strong, readonly) PDFKBasicPDFViewerSinglePageCollectionView *pageCollectionView; +/** + Wether or not the view is showing a single page. + */ +@property (nonatomic, assign, readonly) BOOL showingSinglePage; +/** + The collection view that displays all the thumbs. + */ +@property (nonatomic, strong, readonly) PDFKBasicPDFViewerThumbsCollectionView *thumbsCollectionView; +/** + Wether or not the thumbs collection view is showing thumbs. + */ +@property (nonatomic, assign, readonly) BOOL showingBookmarks; +/** + YES once view did load called. + */ +@property (nonatomic, assign, readonly) BOOL loadedView; + +/** + title of the button for going back from thumbnail-view to page-view + */ +@property (nonatomic, strong) NSString *backButtonTitle; @end diff --git a/Classes/View/PDFKBasicPDFViewer.m b/Classes/View/PDFKBasicPDFViewer.m index b90b837..6aa2706 100644 --- a/Classes/View/PDFKBasicPDFViewer.m +++ b/Classes/View/PDFKBasicPDFViewer.m @@ -21,58 +21,27 @@ #import "PDFKBasicPDFViewerSinglePageCollectionView.h" #import + @interface PDFKBasicPDFViewer () -/** - The toolbar displaied at the top of the screen. - */ -@property (nonatomic, retain) UIToolbar *navigationToolbar; -/** - The slider at the bottom of the screen to show the thumbnails. - */ -@property (nonatomic, retain) UIToolbar *thumbnailSlider; -/** - The popover controller to share the document on the iPad. - */ -@property (nonatomic, strong) UIPopoverController *activityPopoverController; -/** - The share button. - */ -@property (nonatomic, strong) UIBarButtonItem *shareItem; -/** - The item that notes wether or not the page is bookmarked. - */ -@property (nonatomic, strong) UIBarButtonItem *bookmarkItem; -/** - The page scrubber at the bottom of the view. - */ -@property (nonatomic, strong) PDFKPageScrubber *pageScrubber; -/** - The collection view of single pages to display. - */ -@property (nonatomic, strong) PDFKBasicPDFViewerSinglePageCollectionView *pageCollectionView; -/** - Wether or not the view is showing a single page. - */ -@property (nonatomic, assign) BOOL showingSinglePage; -/** - The collection view that displays all the thumbs. - */ -@property (nonatomic, strong) PDFKBasicPDFViewerThumbsCollectionView *thumbsCollectionView; -/** - Wether or not the thumbs collection view is showing thumbs. - */ -@property (nonatomic, assign) BOOL showingBookmarks; -/** - YES once view did load called. - */ -@property (nonatomic, assign) BOOL loadedView; +@property (nonatomic, retain, readwrite) UIToolbar *navigationToolbar; +@property (nonatomic, retain, readwrite) UIToolbar *thumbnailSlider; +@property (nonatomic, strong, readwrite) UIPopoverController *activityPopoverController; +@property (nonatomic, strong, readwrite) UIBarButtonItem *shareItem; +@property (nonatomic, strong, readwrite) UIBarButtonItem *bookmarkItem; +@property (nonatomic, strong, readwrite) PDFKPageScrubber *pageScrubber; +@property (nonatomic, strong, readwrite) PDFKBasicPDFViewerSinglePageCollectionView *pageCollectionView; +@property (nonatomic, assign, readwrite) BOOL showingSinglePage; +@property (nonatomic, strong, readwrite) PDFKBasicPDFViewerThumbsCollectionView *thumbsCollectionView; +@property (nonatomic, assign, readwrite) BOOL showingBookmarks; +@property (nonatomic, assign, readwrite) BOOL loadedView; @property (nonatomic, strong) UITapGestureRecognizer *singleTapGestureRecognizer; @property (nonatomic, strong) UITapGestureRecognizer *doubleTapGestureRecognizer; @end + @implementation PDFKBasicPDFViewer #pragma mark - Initalization and Loading @@ -290,15 +259,6 @@ - (void)resetNavigationToolbar UIBarButtonItem *listItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Thumbs"] landscapeImagePhone:[UIImage imageNamed:@"Thumbs"] style:UIBarButtonItemStylePlain target:self action:@selector(list)]; [buttonsArray addObject:listItem]; - //Sharing Button - if (_enableSharing || _enablePrinting || _enableOpening) { - UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; - space.width = 10.0; - [buttonsArray addObject:space]; - _shareItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(send)]; - [buttonsArray addObject:_shareItem]; - } - //Flexible space [buttonsArray addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]]; @@ -318,6 +278,15 @@ - (void)resetNavigationToolbar [buttonsArray addObject:_bookmarkItem]; } + + //Sharing Button + if (_enableSharing || _enablePrinting || _enableOpening) { + UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; + space.width = 10.0; + [buttonsArray addObject:space]; + _shareItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(send)]; + [buttonsArray addObject:_shareItem]; + } } else { //Set controls for thumbs @@ -335,7 +304,10 @@ - (void)resetNavigationToolbar } //Go back - UIBarButtonItem *listItem = [[UIBarButtonItem alloc] initWithTitle:@"Resume" style:UIBarButtonItemStylePlain target:self action:@selector(list)]; + if (!self.backButtonTitle) { + self.backButtonTitle = @"Resume"; + } + UIBarButtonItem *listItem = [[UIBarButtonItem alloc] initWithTitle:self.backButtonTitle style:UIBarButtonItemStylePlain target:self action:@selector(list)]; [buttonsArray addObject:listItem]; //Flexible space diff --git a/Classes/View/PDFKPageScrubber.h b/Classes/View/PDFKPageScrubber.h index 45372d7..554d9e7 100644 --- a/Classes/View/PDFKPageScrubber.h +++ b/Classes/View/PDFKPageScrubber.h @@ -57,6 +57,17 @@ */ @property (nonatomic, weak, readwrite) id scrubberDelegate; +/** + The scrubber's page number label – use for styling. + */ +@property (nonatomic, strong) UILabel *pageNumberLabel; + +/** + the background color of the thumb + defaults to [UIColor colorWithWhite:0.8 ...] + */ +@property (nonatomic, strong) UIColor *thumbBackgroundColor; + /** Initalize the scrubber with the given frame and document. @@ -98,6 +109,6 @@ @return A new thumb view. */ -- (id)initWithFrame:(CGRect)frame small:(BOOL)small; +- (id)initWithFrame:(CGRect)frame small:(BOOL)small andColor:(UIColor *)color; @end diff --git a/Classes/View/PDFKPageScrubber.m b/Classes/View/PDFKPageScrubber.m index ec56895..e523f4a 100644 --- a/Classes/View/PDFKPageScrubber.m +++ b/Classes/View/PDFKPageScrubber.m @@ -65,6 +65,8 @@ @implementation PDFKPageScrubber NSTimer *trackTimer; } +@synthesize pageNumberLabel = pageNumberLabel; + - (id)initWithFrame:(CGRect)frame { return [self initWithFrame:frame document:nil]; @@ -144,6 +146,12 @@ - (id)initWithFrame:(CGRect)frame document:(PDFKDocument *)object return self; } +- (UIColor *)thumbBackgroundColor { + if (!_thumbBackgroundColor) { + return [UIColor colorWithWhite:0.8 alpha:1]; + } + return _thumbBackgroundColor; +} - (void)removeFromSuperview { @@ -241,7 +249,7 @@ - (void)layoutSubviews CGRect thumbRect = CGRectMake(thumbX, thumbY, THUMB_LARGE_WIDTH, THUMB_LARGE_HEIGHT); //Create the thumb view - pageThumbView = [[PDFKPageScrubberThumb alloc] initWithFrame:thumbRect]; + pageThumbView = [[PDFKPageScrubberThumb alloc] initWithFrame:thumbRect small:NO andColor:self.thumbBackgroundColor]; //Z position so that it sits on top of the small thumbs pageThumbView.layer.zPosition = 1.0f; //Add as the first subview of the track control @@ -289,7 +297,7 @@ - (void)layoutSubviews NSString *phrase = document.password; //Create a small thumb view - smallThumbView = [[PDFKPageScrubberThumb alloc] initWithFrame:thumbRect small:YES]; + smallThumbView = [[PDFKPageScrubberThumb alloc] initWithFrame:thumbRect small:YES andColor:self.thumbBackgroundColor]; PDFKThumbRequest *thumbRequest = [PDFKThumbRequest newForView:smallThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; //Request the thumb @@ -525,16 +533,15 @@ @implementation PDFKPageScrubberThumb - (id)initWithFrame:(CGRect)frame { - return [self initWithFrame:frame small:NO]; + return [self initWithFrame:frame small:NO andColor:[UIColor colorWithWhite:0.8 alpha:0]]; } -- (id)initWithFrame:(CGRect)frame small:(BOOL)small +- (id)initWithFrame:(CGRect)frame small:(BOOL)small andColor:(UIColor *)color { if ((self = [super initWithFrame:frame])) { CGFloat value = (small ? 0.6f : 0.7f); // Size based alpha value - - UIColor *background = [UIColor colorWithWhite:0.8f alpha:value]; + UIColor *background = [color colorWithAlphaComponent:value]; self.backgroundColor = background; imageView.backgroundColor = background; diff --git a/M13PDFKit.podspec b/M13PDFKit.podspec index 990da62..46e377e 100644 --- a/M13PDFKit.podspec +++ b/M13PDFKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "M13PDFKit" - s.version = "1.0.3" + s.version = "1.1.0" s.summary = "M13PDFKit is an iBooks like PDF viewer that can be embedded in iOS applications." s.description = <<-DESC @@ -27,11 +27,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI s.platform = :ios, '8.0' - s.source = { :git => "https://github.com/Marxon13/M13PDFKit.git", :tag => "v1.0.3"} + s.source = { :git => "https://github.com/Marxon13/M13PDFKit.git", :tag => "v1.1.0"} s.source_files = 'Classes/**/*.{h,m}' - s.ios.resource_bundle = { 'M13PDFKitResources' => 'Resources/*' } + s.ios.resource_bundle = { 'M13PDFKitResources' => 'Resources/*.png' } s.frameworks = 'Foundation', 'CoreGraphics', 'ImageIO', 'UIKit' diff --git a/M13PDFKit.xcodeproj/project.pbxproj b/M13PDFKit.xcodeproj/project.pbxproj index b6254e2..ec31eb6 100644 --- a/M13PDFKit.xcodeproj/project.pbxproj +++ b/M13PDFKit.xcodeproj/project.pbxproj @@ -8,6 +8,18 @@ /* Begin PBXBuildFile section */ 186C7FBB404D4DA5AD113882 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 88CCBC2FFD064D688D11FAD6 /* libPods.a */; }; + 99FD8AAE1B4569AA0082331C /* Bookmark.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AA21B4569AA0082331C /* Bookmark.png */; }; + 99FD8AAF1B4569AA0082331C /* Bookmark@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AA31B4569AA0082331C /* Bookmark@2x.png */; }; + 99FD8AB01B4569AA0082331C /* Bookmark@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AA41B4569AA0082331C /* Bookmark@3x.png */; }; + 99FD8AB11B4569AA0082331C /* Bookmarked.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AA51B4569AA0082331C /* Bookmarked.png */; }; + 99FD8AB21B4569AA0082331C /* Bookmarked@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AA61B4569AA0082331C /* Bookmarked@2x.png */; }; + 99FD8AB31B4569AA0082331C /* Bookmarked@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AA71B4569AA0082331C /* Bookmarked@3x.png */; }; + 99FD8AB41B4569AA0082331C /* PageList.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AA81B4569AA0082331C /* PageList.png */; }; + 99FD8AB51B4569AA0082331C /* PageList@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AA91B4569AA0082331C /* PageList@2x.png */; }; + 99FD8AB61B4569AA0082331C /* PageList@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AAA1B4569AA0082331C /* PageList@3x.png */; }; + 99FD8AB71B4569AA0082331C /* Thumbs.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AAB1B4569AA0082331C /* Thumbs.png */; }; + 99FD8AB81B4569AA0082331C /* Thumbs@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AAC1B4569AA0082331C /* Thumbs@2x.png */; }; + 99FD8AB91B4569AA0082331C /* Thumbs@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 99FD8AAD1B4569AA0082331C /* Thumbs@3x.png */; }; CA784DA21A1F99A6003F953B /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA784DA11A1F99A6003F953B /* ImageIO.framework */; }; CA86CE8C1A1EAF45009CDD7C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA86CE8B1A1EAF45009CDD7C /* CoreGraphics.framework */; }; CA86CE901A1EAF56009CDD7C /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA86CE8F1A1EAF56009CDD7C /* MessageUI.framework */; }; @@ -48,6 +60,18 @@ /* Begin PBXFileReference section */ 3BC96A8F8D1C3AA80967EB3F /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 88CCBC2FFD064D688D11FAD6 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 99FD8AA21B4569AA0082331C /* Bookmark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Bookmark.png; path = Resources/Bookmark.png; sourceTree = SOURCE_ROOT; }; + 99FD8AA31B4569AA0082331C /* Bookmark@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Bookmark@2x.png"; path = "Resources/Bookmark@2x.png"; sourceTree = SOURCE_ROOT; }; + 99FD8AA41B4569AA0082331C /* Bookmark@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Bookmark@3x.png"; path = "Resources/Bookmark@3x.png"; sourceTree = SOURCE_ROOT; }; + 99FD8AA51B4569AA0082331C /* Bookmarked.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Bookmarked.png; path = Resources/Bookmarked.png; sourceTree = SOURCE_ROOT; }; + 99FD8AA61B4569AA0082331C /* Bookmarked@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Bookmarked@2x.png"; path = "Resources/Bookmarked@2x.png"; sourceTree = SOURCE_ROOT; }; + 99FD8AA71B4569AA0082331C /* Bookmarked@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Bookmarked@3x.png"; path = "Resources/Bookmarked@3x.png"; sourceTree = SOURCE_ROOT; }; + 99FD8AA81B4569AA0082331C /* PageList.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = PageList.png; path = Resources/PageList.png; sourceTree = SOURCE_ROOT; }; + 99FD8AA91B4569AA0082331C /* PageList@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "PageList@2x.png"; path = "Resources/PageList@2x.png"; sourceTree = SOURCE_ROOT; }; + 99FD8AAA1B4569AA0082331C /* PageList@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "PageList@3x.png"; path = "Resources/PageList@3x.png"; sourceTree = SOURCE_ROOT; }; + 99FD8AAB1B4569AA0082331C /* Thumbs.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Thumbs.png; path = Resources/Thumbs.png; sourceTree = SOURCE_ROOT; }; + 99FD8AAC1B4569AA0082331C /* Thumbs@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Thumbs@2x.png"; path = "Resources/Thumbs@2x.png"; sourceTree = SOURCE_ROOT; }; + 99FD8AAD1B4569AA0082331C /* Thumbs@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Thumbs@3x.png"; path = "Resources/Thumbs@3x.png"; sourceTree = SOURCE_ROOT; }; 9B73E826AFCCB1D55EC99EF8 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; CA784DA11A1F99A6003F953B /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; CA86CE8B1A1EAF45009CDD7C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -139,6 +163,25 @@ name = Pods; sourceTree = ""; }; + 99FD8ABA1B4569AE0082331C /* Images */ = { + isa = PBXGroup; + children = ( + 99FD8AA21B4569AA0082331C /* Bookmark.png */, + 99FD8AA31B4569AA0082331C /* Bookmark@2x.png */, + 99FD8AA41B4569AA0082331C /* Bookmark@3x.png */, + 99FD8AA51B4569AA0082331C /* Bookmarked.png */, + 99FD8AA61B4569AA0082331C /* Bookmarked@2x.png */, + 99FD8AA71B4569AA0082331C /* Bookmarked@3x.png */, + 99FD8AA81B4569AA0082331C /* PageList.png */, + 99FD8AA91B4569AA0082331C /* PageList@2x.png */, + 99FD8AAA1B4569AA0082331C /* PageList@3x.png */, + 99FD8AAB1B4569AA0082331C /* Thumbs.png */, + 99FD8AAC1B4569AA0082331C /* Thumbs@2x.png */, + 99FD8AAD1B4569AA0082331C /* Thumbs@3x.png */, + ); + name = Images; + sourceTree = ""; + }; CAF256291A1CFF0000F0EA4F = { isa = PBXGroup; children = ( @@ -163,6 +206,7 @@ isa = PBXGroup; children = ( CAF2565B1A1CFF2C00F0EA4F /* Classes */, + 99FD8ABA1B4569AE0082331C /* Images */, CAF256391A1CFF0000F0EA4F /* AppDelegate.h */, CAF2563A1A1CFF0000F0EA4F /* AppDelegate.m */, CA86CE911A1EB311009CDD7C /* SamplesTableViewController.h */, @@ -344,9 +388,21 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 99FD8AB71B4569AA0082331C /* Thumbs.png in Resources */, + 99FD8AB91B4569AA0082331C /* Thumbs@3x.png in Resources */, CA86CE971A1EB561009CDD7C /* Wikipedia.pdf in Resources */, + 99FD8AB01B4569AA0082331C /* Bookmark@3x.png in Resources */, + 99FD8AAF1B4569AA0082331C /* Bookmark@2x.png in Resources */, + 99FD8AB31B4569AA0082331C /* Bookmarked@3x.png in Resources */, + 99FD8AAE1B4569AA0082331C /* Bookmark.png in Resources */, + 99FD8AB11B4569AA0082331C /* Bookmarked.png in Resources */, + 99FD8AB21B4569AA0082331C /* Bookmarked@2x.png in Resources */, CAF256411A1CFF0000F0EA4F /* Main.storyboard in Resources */, + 99FD8AB41B4569AA0082331C /* PageList.png in Resources */, CAF256431A1CFF0100F0EA4F /* Images.xcassets in Resources */, + 99FD8AB81B4569AA0082331C /* Thumbs@2x.png in Resources */, + 99FD8AB61B4569AA0082331C /* PageList@3x.png in Resources */, + 99FD8AB51B4569AA0082331C /* PageList@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; };