Skip to content

Commit

Permalink
Added anchor height property to the CalloutBackgroundView for custom …
Browse files Browse the repository at this point in the history
…background view with custom arrow.
  • Loading branch information
rousseauo committed Feb 12, 2015
1 parent 4cb0b99 commit 0b65a72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions SMCalloutView.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extern NSTimeInterval const kSMCalloutViewRepositionDelayForUIScrollView;
@property (nonatomic, assign) CGPoint arrowPoint; // indicates where the tip of the arrow should be drawn, as a pixel offset
@property (nonatomic, assign) BOOL highlighted; // will be set by the callout when the callout is in a highlighted state
@property (nonatomic, assign) CALayer *contentMask; // returns an optional layer whose contents should mask the callout view's contents (not honored by SMClassicCalloutView)
@property (nonatomic, assign) CGFloat anchorHeight; //The arrow height, useful for custom background view with custom arrow
@end

// Default for iOS 7, this reproduces the "masked" behavior of the iOS 7-style callout view.
Expand Down
10 changes: 8 additions & 2 deletions SMCalloutView.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ @interface UIView (SMFrameAdditions)
#define BETWEEN_ACCESSORIES_MARGIN 7 // margin between accessories when no title/subtitle is present
#define CONTENT_VIEW_MARGIN 12 // margin around content view when present, can be overridden with contentViewMargin
#define ANCHOR_MARGIN 27 // the smallest possible distance from the edge of our control to the "tip" of the anchor, from either left or right
#define ANCHOR_HEIGHT 13 // effective height of the anchor
#define DEFAULT_ANCHOR_HEIGHT 13 // effective height of the anchor, will be overriden by anchorHeight propertiy of the SMCalloutBackgroundView if asigned.
#define TOP_ANCHOR_MARGIN 13 // all the above measurements assume a bottom anchor! if we're pointing "up" we'll need to add this top margin to everything.
#define COMFORTABLE_MARGIN 10 // when we try to reposition content to be visible, we'll consider this margin around your target rect

Expand Down Expand Up @@ -197,7 +197,13 @@ - (CGFloat)innerContentMarginRight {
}

- (CGFloat)calloutHeight {
return self.calloutContainerHeight + ANCHOR_HEIGHT;
if(self.backgroundView.anchorHeight)
{
return self.calloutContainerHeight + self.backgroundView.anchorHeight;
}
else {
return self.calloutContainerHeight + DEFAULT_ANCHOR_HEIGHT;
}
}

- (CGFloat)calloutContainerHeight {
Expand Down

0 comments on commit 0b65a72

Please sign in to comment.