Skip to content
Open
Show file tree
Hide file tree
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 Default-568h@2x.png
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
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; 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>"; };
Expand Down Expand Up @@ -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 */,
);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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";
Expand Down
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' => 'contact@victorpena.es' }
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
Expand Up @@ -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 */

Expand Down
48 changes: 41 additions & 7 deletions PrettyKit/Cells/PrettyTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -367,7 +367,6 @@ @implementation PrettyTableViewCell
@synthesize customBackgroundColor, gradientStartColor, gradientEndColor;
@synthesize shadowOpacity, customSeparatorStyle;


- (void) dealloc
{
[self.contentView removeObserver:self forKeyPath:@"frame"];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down