diff --git a/FPPopoverController.h b/FPPopoverController.h index 9eda7c1..0277f24 100644 --- a/FPPopoverController.h +++ b/FPPopoverController.h @@ -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; diff --git a/FPPopoverController.m b/FPPopoverController.m index e9943c4..798ac59 100644 --- a/FPPopoverController.m +++ b/FPPopoverController.m @@ -54,6 +54,7 @@ @implementation FPPopoverController @synthesize tint = _tint; @synthesize border = _border; @synthesize alpha = _alpha; +@synthesize radius = _radius; -(void)addObservers { @@ -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]; @@ -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 { @@ -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 diff --git a/FPPopoverDemo.xcodeproj/project.pbxproj b/FPPopoverDemo.xcodeproj/project.pbxproj index 2ff8fea..44e54ca 100644 --- a/FPPopoverDemo.xcodeproj/project.pbxproj +++ b/FPPopoverDemo.xcodeproj/project.pbxproj @@ -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" */; @@ -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; @@ -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; diff --git a/FPPopoverDemo/FPViewController.m b/FPPopoverDemo/FPViewController.m index 00c0c5a..54c2a97 100644 --- a/FPPopoverDemo/FPViewController.m +++ b/FPPopoverDemo/FPViewController.m @@ -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); @@ -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 { @@ -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; diff --git a/FPPopoverView.h b/FPPopoverView.h index d3bc5c9..d9cbdc6 100644 --- a/FPPopoverView.h +++ b/FPPopoverView.h @@ -10,6 +10,8 @@ #import #import +#define FP_POPOVER_RADIUS 10.0 + typedef enum FPPopoverArrowDirection: NSUInteger { FPPopoverArrowDirectionUp = 1UL << 0, FPPopoverArrowDirectionDown = 1UL << 1, @@ -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; diff --git a/FPPopoverView.m b/FPPopoverView.m index f3bf62e..06d01f1 100644 --- a/FPPopoverView.m +++ b/FPPopoverView.m @@ -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() @@ -36,6 +36,7 @@ @implementation FPPopoverView @synthesize tint = _tint; @synthesize draw3dBorder = _draw3dBorder; @synthesize border = _border; +@synthesize radius = _radius; -(void)dealloc { @@ -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]; @@ -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; } } @@ -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 @@ -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); } }