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
1 change: 1 addition & 0 deletions FPPopoverController.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
@property(nonatomic,assign) CGSize contentSize;
@property(nonatomic,assign) CGPoint origin;
@property(nonatomic,assign) CGFloat alpha;
@property(nonatomic,assign) CGFloat radius;

/** @brief The tint of the popover. **/
@property(nonatomic,assign) FPPopoverTint tint;
Expand Down
24 changes: 23 additions & 1 deletion FPPopoverController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ @implementation FPPopoverController
@synthesize tint = _tint;
@synthesize border = _border;
@synthesize alpha = _alpha;
@synthesize radius = _radius;

-(void)addObservers
{
Expand Down Expand Up @@ -115,6 +116,7 @@ -(id)initWithViewController:(UIViewController*)viewController
self.arrowDirection = FPPopoverArrowDirectionAny;
self.view.userInteractionEnabled = YES;
_border = YES;
_radius = FP_POPOVER_RADIUS;

_touchView = [[FPTouchView alloc] initWithFrame:self.view.bounds];
_touchView.backgroundColor = [UIColor clearColor];
Expand Down Expand Up @@ -150,16 +152,18 @@ -(id)initWithViewController:(UIViewController*)viewController

_touchView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_touchView.clipsToBounds = NO;

//setting contentview
_contentView.title = _viewController.title;
_contentView.clipsToBounds = NO;
_contentView.radius = _radius;

[_viewController addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:nil];
}
return self;
}

#pragma mark - Property overrides

-(void)setTint:(FPPopoverTint)tint
{
Expand All @@ -172,6 +176,24 @@ -(FPPopoverTint)tint
return _contentView.tint;
}

-(void)setRadius:(CGFloat)radius {
_contentView.radius = radius;
[_contentView setNeedsDisplay];
}

-(CGFloat)radius {
return _contentView.radius;
}

-(void)setTitle:(NSString *)title {
_contentView.title = title;
[_contentView setNeedsDisplay];
}

-(NSString*)title {
return _contentView.title;
}

#pragma mark - View lifecycle

-(void)setupView
Expand Down
10 changes: 9 additions & 1 deletion FPPopoverDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = FP;
LastUpgradeCheck = 0430;
LastUpgradeCheck = 0460;
ORGANIZATIONNAME = "Fifty Pixels Ltd";
};
buildConfigurationList = 186C43691538512100502D64 /* Build configuration list for PBXProject "FPPopoverDemo" */;
Expand Down Expand Up @@ -554,6 +554,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 @@ -579,6 +583,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 = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down
3 changes: 2 additions & 1 deletion FPPopoverDemo/FPViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ -(IBAction)popover:(id)sender
popover = [[FPPopoverController alloc] initWithViewController:controller];
popover.tint = FPPopoverDefaultTint;


if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
popover.contentSize = CGSizeMake(300, 500);
Expand All @@ -78,6 +77,7 @@ -(IBAction)popover:(id)sender
if(sender == _noArrow) {
//no arrow
popover.arrowDirection = FPPopoverNoArrow;
popover.title = nil;
[popover presentPopoverFromPoint: CGPointMake(self.view.center.x, self.view.center.y - popover.contentSize.height/2)];
}
else {
Expand Down Expand Up @@ -166,6 +166,7 @@ -(IBAction)navControllerPopover:(id)sender
popover = [[FPPopoverController alloc] initWithViewController:nc];
popover.tint = FPPopoverDefaultTint;
popover.contentSize = CGSizeMake(300, 500);
popover.radius = 5.0;
[popover presentPopoverFromView:sender];

// CGRect nc_bar_frame = nc.navigationBar.frame;
Expand Down
3 changes: 3 additions & 0 deletions FPPopoverView.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

#define FP_POPOVER_RADIUS 10.0

typedef enum FPPopoverArrowDirection: NSUInteger {
FPPopoverArrowDirectionUp = 1UL << 0,
FPPopoverArrowDirectionDown = 1UL << 1,
Expand Down Expand Up @@ -49,6 +51,7 @@ typedef enum {
@property(nonatomic,assign) FPPopoverTint tint;
@property(nonatomic,assign) BOOL draw3dBorder;
@property(nonatomic,assign) BOOL border; //default YES
@property(nonatomic,assign) CGFloat radius; //default 10.0

-(void)setArrowDirection:(FPPopoverArrowDirection)arrowDirection;
-(FPPopoverArrowDirection)arrowDirection;
Expand Down
22 changes: 17 additions & 5 deletions FPPopoverView.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define FP_POPOVER_ARROW_HEIGHT 20.0
#define FP_POPOVER_ARROW_BASE 20.0
#define FP_POPOVER_RADIUS 10.0


//iVars
@interface FPPopoverView()
Expand All @@ -36,6 +36,7 @@ @implementation FPPopoverView
@synthesize tint = _tint;
@synthesize draw3dBorder = _draw3dBorder;
@synthesize border = _border;
@synthesize radius = _radius;

-(void)dealloc
{
Expand Down Expand Up @@ -69,6 +70,9 @@ - (id)initWithFrame:(CGRect)frame

//border
self.border = YES;

//radius
self.radius = FP_POPOVER_RADIUS;

_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_titleLabel.backgroundColor = [UIColor clearColor];
Expand Down Expand Up @@ -114,7 +118,15 @@ -(void)setBorder:(BOOL)border
_contentView.clipsToBounds = YES;
self.clipsToBounds = YES;
self.draw3dBorder = NO;
_contentView.layer.cornerRadius = FP_POPOVER_RADIUS;
_contentView.layer.cornerRadius = _radius;
}
}

-(void)setRadius:(CGFloat)radius
{
_radius = radius;
if(self.border == NO) {
_contentView.layer.cornerRadius = _radius;
}
}

Expand All @@ -127,7 +139,7 @@ -(CGPathRef)newContentPathWithBorderWidth:(CGFloat)borderWidth arrowDirection:(F
CGFloat h = self.bounds.size.height;
CGFloat ah = FP_POPOVER_ARROW_HEIGHT; //is the height of the triangle of the arrow
CGFloat aw = FP_POPOVER_ARROW_BASE/2.0; //is the 1/2 of the base of the arrow
CGFloat radius = FP_POPOVER_RADIUS;
CGFloat radius = self.radius;
CGFloat b = borderWidth;

//NO BORDER
Expand Down Expand Up @@ -504,8 +516,8 @@ -(void)setupViews
contentRect.size = CGSizeMake(self.bounds.size.width-20, self.bounds.size.height-50);
_titleLabel.frame = CGRectMake(10, 10, self.bounds.size.width-20, 20);
if (self.title==nil || self.title.length==0) {
contentRect.origin = CGPointMake(10, 30);
contentRect.size = CGSizeMake(self.bounds.size.width-20, self.bounds.size.height-40);
contentRect.origin = CGPointMake(10, 10);
contentRect.size = CGSizeMake(self.bounds.size.width-20, self.bounds.size.height-20);
}
}

Expand Down