Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue #34 #47

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion PrettyExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -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 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 8AE3DA6A17C3E1CB004E9D8A /* [email protected] */; };
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 = "<group>"; };
57CF9FAF151BA08600BC035B /* PlainExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlainExample.m; sourceTree = "<group>"; };
57CF9FB0151BA08600BC035B /* PlainExample.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PlainExample.xib; sourceTree = "<group>"; };
8AE3DA6A17C3E1CB004E9D8A /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "../[email protected]"; sourceTree = "<group>"; };
EDA7DCAF1548EBD1002219BA /* PrettyToolbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrettyToolbar.h; sourceTree = "<group>"; };
EDA7DCB01548EBD1002219BA /* PrettyToolbar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrettyToolbar.m; sourceTree = "<group>"; };
EDA7DCB31548ED3E002219BA /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalViewController.h; sourceTree = "<group>"; };
@@ -144,6 +146,7 @@
57CF9FB0151BA08600BC035B /* PlainExample.xib */,
572B2E6415348E1B0002228B /* RotableTabBarController.h */,
572B2E6515348E1B0002228B /* RotableTabBarController.m */,
8AE3DA6A17C3E1CB004E9D8A /* [email protected] */,
572B2E68153496870002228B /* background.png */,
572B2E69153496870002228B /* [email protected] */,
);
@@ -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 /* [email protected] in Resources */,
EDA7DCB71548ED3F002219BA /* ModalViewController.xib in Resources */,
8AE3DA6B17C3E1CB004E9D8A /* [email protected] 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";
13 changes: 13 additions & 0 deletions PrettyKit.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Pod::Spec.new do |s|
s.name = 'PrettyKit'
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' => '[email protected]' }
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'
s.frameworks = 'UIKit', 'QuartzCore', 'CoreGraphics'
end
6 changes: 5 additions & 1 deletion PrettyKit/Cells/PrettyTableViewCell.h
Original file line number Diff line number Diff line change
@@ -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 default value is 4 by default. */
+ (CGFloat) shadowGroupedMargin;
+ (void) setShadowGroupedMargin:(CGFloat) shadowMargin;

/** @name Cell status */

48 changes: 41 additions & 7 deletions PrettyKit/Cells/PrettyTableViewCell.m
Original file line number Diff line number Diff line change
@@ -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"];
@@ -398,6 +397,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];
@@ -452,18 +475,28 @@ + (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;
}
}

+ (CGFloat)shadowGroupedMargin
{
return _shadowGroupedMargin;
}

+ (void)setShadowGroupedMargin:(CGFloat)shadowMargin
{
_shadowGroupedMargin = 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
@@ -499,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;
}
}
@@ -534,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