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

change arrow size #81

Open
hsavit1 opened this issue May 6, 2015 · 5 comments
Open

change arrow size #81

hsavit1 opened this issue May 6, 2015 · 5 comments

Comments

@hsavit1
Copy link

hsavit1 commented May 6, 2015

how can I do this? The arrow is hardcoded

@rousseauo
Copy link
Contributor

Maybe it is not the best way to change the arrow size but you can use a custom arrow by implementing your own SMCalloutBackgroundView.

@interface CustomCalloutBackgroundView : SMCalloutBackgroundView

Set the image, anchorHeight, anchorMargin in the init and layout it as you need in the layoutSubviews.

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {

        self.containerView = [UIView new];
        self.containerView.backgroundColor = [UIColor colorWithWhite:1.0f alpha:0.75f];

        whiteArrowImage = [UIImage imageNamed:@"my_big_custom_arrow"];

        self.anchorHeight = [NSNumber numberWithFloat:whiteArrowImage.size.height];
        self.anchorMargin = whiteArrowImage.size.width;

        self.arrowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, whiteArrowImage.size.width, whiteArrowImage.size.height)];
        self.arrowImageView = [[UIImageView alloc] initWithImage:whiteArrowImage];

        [self addSubview:self.containerView];
        [self addSubview:self.arrowView];
        [self.arrowView addSubview:self.arrowImageView];
    }
    return self;
}

- (void)layoutSubviews {
    self.containerView.frame = CGRectMake(0, 0, self.$width, self.$height - self.arrowView.$height);

    self.arrowView.$x = self.arrowPoint.x;
    self.arrowView.$y = self.containerView.$height;
    self.arrowView.transform = CGAffineTransformIdentity;
}

Then set your custom background to your callout

[myCallout setBackgroundView:[[CustomCalloutBackgroundView alloc] init]]

@nfarina
Copy link
Owner

nfarina commented May 6, 2015

@rousseauo is correct that a custom background will be needed to change the arrow, since the arrow is based on a static image. You could create your own static arrow image and use it instead if you want to draw it the same way.

@hsavit1
Copy link
Author

hsavit1 commented May 6, 2015

Do you know how to encode an image into data as it is currently done in the
project?

Btw- thanks for the blazing fast response!!

On Tuesday, May 5, 2015, Nick Farina [email protected] wrote:

@rousseauo https://github.com/rousseauo is correct that a custom
background will be needed to change the arrow, since the arrow is based on
a static image. You could create your own static arrow image and use it
instead if you want to draw it the same way.


Reply to this email directly or view it on GitHub
#81 (comment).

Sent from Gmail Mobile

@nfarina
Copy link
Owner

nfarina commented May 6, 2015

Take a look at SampleAssets/SystemGraphics/process_images.py to see how the included images are encoded.

@hsavit1
Copy link
Author

hsavit1 commented May 6, 2015

I guess I'll have to open a py shell and try it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants