calloutview icon indicating copy to clipboard operation
calloutview copied to clipboard

change arrow size

Open hsavit1 opened this issue 9 years ago • 5 comments

how can I do this? The arrow is hardcoded

hsavit1 avatar May 06 '15 03:05 hsavit1

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]]

rousseauo avatar May 06 '15 03:05 rousseauo

@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.

nfarina avatar May 06 '15 03:05 nfarina

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 https://github.com/nfarina/calloutview/issues/81#issuecomment-99310558.

Sent from Gmail Mobile

hsavit1 avatar May 06 '15 03:05 hsavit1

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

nfarina avatar May 06 '15 03:05 nfarina

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

hsavit1 avatar May 06 '15 04:05 hsavit1