From ca5aea898bd8b5c23c1a74373513d3a86f58acae Mon Sep 17 00:00:00 2001 From: Alexandre Date: Fri, 16 Aug 2013 12:38:24 -0300 Subject: [PATCH 1/7] Fixing issue #34 Fixed support for cell instantiation from storyboard. --- PrettyKit/Cells/PrettyTableViewCell.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/PrettyKit/Cells/PrettyTableViewCell.m b/PrettyKit/Cells/PrettyTableViewCell.m index 8857b8b..1f40ec2 100644 --- a/PrettyKit/Cells/PrettyTableViewCell.m +++ b/PrettyKit/Cells/PrettyTableViewCell.m @@ -398,6 +398,30 @@ - (void)initializeVars self.customSeparatorStyle = UITableViewCellSeparatorStyleSingleLine; } +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super initWithCoder:aDecoder]; + if (self) + { + [self.contentView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionOld context:nil]; + + PrettyTableViewCellBackground *bg = [[PrettyTableViewCellBackground alloc] initWithFrame:self.frame + behavior:CellBackgroundBehaviorNormal]; + bg.cell = self; + self.backgroundView = bg; + [bg release]; + + bg = [[PrettyTableViewCellBackground alloc] initWithFrame:self.frame + behavior:CellBackgroundBehaviorSelected]; + bg.cell = self; + self.selectedBackgroundView = bg; + [bg release]; + + [self initializeVars]; + } + return self; +} + - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; From c64381d8005a0322c80e1ffddb8d28bd7fe7c792 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Tue, 20 Aug 2013 13:12:36 -0300 Subject: [PATCH 2/7] Adding podspec file --- PrettyKit.podspec | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 PrettyKit.podspec diff --git a/PrettyKit.podspec b/PrettyKit.podspec new file mode 100644 index 0000000..759854d --- /dev/null +++ b/PrettyKit.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = 'PrettyKit' + s.version = '0.2.1' + s.license = 'MIT' + s.summary = 'PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization.' + s.homepage = 'http://github.com/alexandreos/PrettyKit' + s.author = { 'Victor Pena' => 'contact@victorpena.es' } + s.source = { :git => 'https://github.com/alexandreos/PrettyKit.git', :tag => '0.2.1' } + s.description = 'PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization. You will be able to change their background color, add gradients, shadows, etc.' + s.platform = :ios + s.source_files = 'PrettyKit', 'PrettyKit/Cells' + s.frameworks = 'UIKit', 'QuartzCore', 'CoreGraphics' +end \ No newline at end of file From 4c27a1834d8fe2d8fdbac038d0cd322203869719 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Tue, 20 Aug 2013 14:48:55 -0300 Subject: [PATCH 3/7] Added support for margin configuration --- Default-568h@2x.png | Bin 0 -> 18594 bytes PrettyExample.xcodeproj/project.pbxproj | 16 +++++++++++++++- PrettyKit/Cells/PrettyTableViewCell.h | 6 +++++- PrettyKit/Cells/PrettyTableViewCell.m | 15 ++++++++++++--- 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 Default-568h@2x.png diff --git a/Default-568h@2x.png b/Default-568h@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0891b7aabfcf3422423b109c8beed2bab838c607 GIT binary patch literal 18594 zcmeI4X;f257Jx&9fS`ixvS;&$x8J@slQFSel)6zJN=?13FB7H(lQjRkSy8x_-S~tvu2gzn1oS+dLcF#eqtq$ z%tf9TTvX?`)R@}3uBI;jzS-=ZR-Td&MHaS&;!0?Ni*#$#`n*~CcQK)Q9vAQ~TUpnI!j)a2biYK^R)M~A5wUDZhx?ULMX z3x1P&qt=trOY6P2U67L=m=U?F|5#Uj(eCueNTZaHs_ceWiHeET+j+tp3Jt9g(ekqP z2WOvfR{qV+9r+o4J5?qK>7;;^+I7tGv-i)es$X_D=EoKF+S?zsyj^oRFElP}c}JT< zd8SUs-?O?}2YD#ngK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xcodeproj/project.pbxproj index d150374..ede6522 100644 --- a/PrettyExample.xcodeproj/project.pbxproj +++ b/PrettyExample.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ 57A6337614FE7672004D2647 /* ExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 57A6337514FE7672004D2647 /* ExampleViewController.m */; }; 57CF9FB1151BA08600BC035B /* PlainExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 57CF9FAF151BA08600BC035B /* PlainExample.m */; }; 57CF9FB2151BA08600BC035B /* PlainExample.xib in Resources */ = {isa = PBXBuildFile; fileRef = 57CF9FB0151BA08600BC035B /* PlainExample.xib */; }; + 8AE3DA6B17C3E1CB004E9D8A /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8AE3DA6A17C3E1CB004E9D8A /* Default-568h@2x.png */; }; EDA7DCB11548EBD1002219BA /* PrettyToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = EDA7DCB01548EBD1002219BA /* PrettyToolbar.m */; }; EDA7DCB61548ED3F002219BA /* ModalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EDA7DCB41548ED3E002219BA /* ModalViewController.m */; }; EDA7DCB71548ED3F002219BA /* ModalViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = EDA7DCB51548ED3E002219BA /* ModalViewController.xib */; }; @@ -75,6 +76,7 @@ 57CF9FAE151BA08600BC035B /* PlainExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlainExample.h; sourceTree = ""; }; 57CF9FAF151BA08600BC035B /* PlainExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlainExample.m; sourceTree = ""; }; 57CF9FB0151BA08600BC035B /* PlainExample.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PlainExample.xib; sourceTree = ""; }; + 8AE3DA6A17C3E1CB004E9D8A /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = ""; }; EDA7DCAF1548EBD1002219BA /* PrettyToolbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrettyToolbar.h; sourceTree = ""; }; EDA7DCB01548EBD1002219BA /* PrettyToolbar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrettyToolbar.m; sourceTree = ""; }; EDA7DCB31548ED3E002219BA /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalViewController.h; sourceTree = ""; }; @@ -144,6 +146,7 @@ 57CF9FB0151BA08600BC035B /* PlainExample.xib */, 572B2E6415348E1B0002228B /* RotableTabBarController.h */, 572B2E6515348E1B0002228B /* RotableTabBarController.m */, + 8AE3DA6A17C3E1CB004E9D8A /* Default-568h@2x.png */, 572B2E68153496870002228B /* background.png */, 572B2E69153496870002228B /* background@2x.png */, ); @@ -221,7 +224,7 @@ 5735F8AE14FD2FFC00DD7370 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0420; + LastUpgradeCheck = 0460; }; buildConfigurationList = 5735F8B114FD2FFC00DD7370 /* Build configuration list for PBXProject "PrettyExample" */; compatibilityVersion = "Xcode 3.2"; @@ -252,6 +255,7 @@ 572B2E6A153496880002228B /* background.png in Resources */, 572B2E6B153496880002228B /* background@2x.png in Resources */, EDA7DCB71548ED3F002219BA /* ModalViewController.xib in Resources */, + 8AE3DA6B17C3E1CB004E9D8A /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -299,6 +303,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -312,6 +320,7 @@ GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 4.0; SDKROOT = iphoneos; @@ -323,12 +332,17 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 4.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; diff --git a/PrettyKit/Cells/PrettyTableViewCell.h b/PrettyKit/Cells/PrettyTableViewCell.h index 98ede26..adb8981 100644 --- a/PrettyKit/Cells/PrettyTableViewCell.h +++ b/PrettyKit/Cells/PrettyTableViewCell.h @@ -226,7 +226,11 @@ typedef enum { property to NO. */ + (CGFloat) tableView:(UITableView *)tableView neededHeightForIndexPath:(NSIndexPath *)indexPath; - +/** Indicates the shadow margin to use in grouped table views. + + Its value is 4 by default. */ ++ (CGFloat) shadowGroupedMargin; ++ (void) setShadowGroupedMargin:(CGFloat) shadowMargin; /** @name Cell status */ diff --git a/PrettyKit/Cells/PrettyTableViewCell.m b/PrettyKit/Cells/PrettyTableViewCell.m index 1f40ec2..7d50755 100644 --- a/PrettyKit/Cells/PrettyTableViewCell.m +++ b/PrettyKit/Cells/PrettyTableViewCell.m @@ -70,12 +70,12 @@ - (BOOL) tableViewIsGrouped { } - (float) shadowMargin { - return [self tableViewIsGrouped] ? shadow_margin : 0; + return [self tableViewIsGrouped] ? [PrettyTableViewCell shadowGroupedMargin] : 0; } @end - +static CGFloat _shadowGroupedMargin = shadow_margin; // http://www.raywenderlich.com/2033/core-graphics-101-lines-rectangles-and-gradients // https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CGContext/Reference/reference.html @@ -367,7 +367,6 @@ @implementation PrettyTableViewCell @synthesize customBackgroundColor, gradientStartColor, gradientEndColor; @synthesize shadowOpacity, customSeparatorStyle; - - (void) dealloc { [self.contentView removeObserver:self forKeyPath:@"frame"]; @@ -484,6 +483,16 @@ + (CGFloat) neededHeightForPosition:(PrettyTableViewCellPosition)position tableS } } ++ (CGFloat)shadowGroupedMargin +{ + return _shadowGroupedMargin; +} + ++ (void)setShadowGroupedMargin:(CGFloat)shadowMargin +{ + _shadowGroupedMargin = shadowMargin; +} + + (CGFloat) tableView:(UITableView *)tableView neededHeightForIndexPath:(NSIndexPath *)indexPath { PrettyTableViewCellPosition position = [PrettyTableViewCell positionForTableView:tableView indexPath:indexPath]; From ce9df49e7168d8db1f511539d4f7cffbcb52e0d6 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Tue, 20 Aug 2013 14:51:19 -0300 Subject: [PATCH 4/7] Update podspec --- PrettyKit.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PrettyKit.podspec b/PrettyKit.podspec index 759854d..f5d3466 100644 --- a/PrettyKit.podspec +++ b/PrettyKit.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'PrettyKit' - s.version = '0.2.1' + s.version = '0.2.2' s.license = 'MIT' s.summary = 'PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization.' s.homepage = 'http://github.com/alexandreos/PrettyKit' s.author = { 'Victor Pena' => 'contact@victorpena.es' } - s.source = { :git => 'https://github.com/alexandreos/PrettyKit.git', :tag => '0.2.1' } + s.source = { :git => 'https://github.com/alexandreos/PrettyKit.git', :tag => '0.2.2' } s.description = 'PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization. You will be able to change their background color, add gradients, shadows, etc.' s.platform = :ios s.source_files = 'PrettyKit', 'PrettyKit/Cells' From 98796129e7ec097bd938cc781fc6ef202a2ef233 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Tue, 20 Aug 2013 15:09:34 -0300 Subject: [PATCH 5/7] Fixing innerFame calculation bug --- PrettyKit/Cells/PrettyTableViewCell.m | 1 + 1 file changed, 1 insertion(+) diff --git a/PrettyKit/Cells/PrettyTableViewCell.m b/PrettyKit/Cells/PrettyTableViewCell.m index 7d50755..87e535a 100644 --- a/PrettyKit/Cells/PrettyTableViewCell.m +++ b/PrettyKit/Cells/PrettyTableViewCell.m @@ -567,6 +567,7 @@ - (CGRect) innerFrame switch (self.position) { case PrettyTableViewCellPositionTop: topMargin = shadowMargin; + break; case PrettyTableViewCellPositionMiddle: // let the separator to be painted, but separator is only painted // in grouped table views From 2253f7c41af49ecc2e38091efff60353699aea22 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Mon, 9 Sep 2013 19:52:42 -0300 Subject: [PATCH 6/7] Adding support for shadow margin customization and fixing support for subclassing. --- PrettyKit/Cells/PrettyTableViewCell.h | 2 +- PrettyKit/Cells/PrettyTableViewCell.m | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PrettyKit/Cells/PrettyTableViewCell.h b/PrettyKit/Cells/PrettyTableViewCell.h index adb8981..7a039bb 100644 --- a/PrettyKit/Cells/PrettyTableViewCell.h +++ b/PrettyKit/Cells/PrettyTableViewCell.h @@ -228,7 +228,7 @@ typedef enum { /** Indicates the shadow margin to use in grouped table views. - Its value is 4 by default. */ + Its default value is 4 by default. */ + (CGFloat) shadowGroupedMargin; + (void) setShadowGroupedMargin:(CGFloat) shadowMargin; diff --git a/PrettyKit/Cells/PrettyTableViewCell.m b/PrettyKit/Cells/PrettyTableViewCell.m index 87e535a..399cf36 100644 --- a/PrettyKit/Cells/PrettyTableViewCell.m +++ b/PrettyKit/Cells/PrettyTableViewCell.m @@ -475,9 +475,9 @@ + (CGFloat) neededHeightForPosition:(PrettyTableViewCellPosition)position tableS { case PrettyTableViewCellPositionBottom: case PrettyTableViewCellPositionTop: - return shadow_margin; + return [self shadowGroupedMargin]; case PrettyTableViewCellPositionAlone: - return shadow_margin*2; + return [self shadowGroupedMargin]*2; default: return 0; } @@ -496,7 +496,7 @@ + (void)setShadowGroupedMargin:(CGFloat)shadowMargin + (CGFloat) tableView:(UITableView *)tableView neededHeightForIndexPath:(NSIndexPath *)indexPath { PrettyTableViewCellPosition position = [PrettyTableViewCell positionForTableView:tableView indexPath:indexPath]; - return [PrettyTableViewCell neededHeightForPosition:position tableStyle:tableView.style]; + return [[self class] neededHeightForPosition:position tableStyle:tableView.style]; } - (void) prepareForTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath @@ -532,7 +532,7 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:( CGRect rect = CGRectMake(originalFrame.origin.x+shadowMargin, originalFrame.origin.y+diffY, originalFrame.size.width - shadowMargin*2, - originalFrame.size.height- contentView_margin*2 - [PrettyTableViewCell neededHeightForPosition:self.position tableStyle:_tableViewStyle]); + originalFrame.size.height- contentView_margin*2 - [[self class] neededHeightForPosition:self.position tableStyle:_tableViewStyle]); contentView.frame = rect; } } From ead1b15c8b4bf2fede06853f38bf51dc712b2217 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Mon, 9 Sep 2013 19:53:47 -0300 Subject: [PATCH 7/7] Releasing version 0.2.3 --- PrettyKit.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PrettyKit.podspec b/PrettyKit.podspec index f5d3466..7f5b255 100644 --- a/PrettyKit.podspec +++ b/PrettyKit.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'PrettyKit' - s.version = '0.2.2' + s.version = '0.2.3' s.license = 'MIT' s.summary = 'PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization.' s.homepage = 'http://github.com/alexandreos/PrettyKit' s.author = { 'Victor Pena' => 'contact@victorpena.es' } - s.source = { :git => 'https://github.com/alexandreos/PrettyKit.git', :tag => '0.2.2' } + s.source = { :git => 'https://github.com/alexandreos/PrettyKit.git', :tag => '0.2.3' } s.description = 'PrettyKit for iOS is a small set of new widgets and UIKit subclasses that gives you a deeper UIKit customization. You will be able to change their background color, add gradients, shadows, etc.' s.platform = :ios s.source_files = 'PrettyKit', 'PrettyKit/Cells'