You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

82 lines
2.9 KiB

//
// UserAnnotationView.m
// watch
//
// Created by WeiChaoZheng on 2017/11/6.
// Copyright © 2017年 xTT. All rights reserved.
//
#import "UserAnnotationView.h"
@interface UserAnnotationView ()
@property (nonatomic,strong) UIImageView* portraitImageView;
@property (nonatomic,strong) UIImageView* backImage;
@end
@implementation UserAnnotationView
- (void)setImageWithURLString:(NSString*)urlString
{
[self.portraitImageView sd_setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:@"icon_adults_occupies_the_head_1"]];
}
- (void)setImageWithString:(NSString*)string
{
[self.backImage setImage:[UIImage imageNamed:string]];
self.backImage.contentMode = UIViewContentModeScaleAspectFit;
}
- (void)setImage:(UIImage *)image
{
[super setImage:image];
//自定义动画
self.transform = CGAffineTransformMakeScale(0.5, 0.5);
// 弹簧动画,参数分别为:时长,延时,弹性(越小弹性越大),初始速度
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.3 initialSpringVelocity:0.3 options:UIViewAnimationOptionLayoutSubviews animations:^{
self.transform = CGAffineTransformMakeScale(1, 1);
} completion:^(BOOL finished) {
}];
}
- (void)setFrame:(CGRect)frame
{
[super setFrame:frame];
self.backImage.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
self.portraitImageView.frame = CGRectMake(0, 0, frame.size.width*2/3, frame.size.width*2/3);
self.portraitImageView.center = CGPointMake(self.backImage.center.x, self.backImage.center.y-5);
self.portraitImageView.layer.cornerRadius = _portraitImageView.bounds.size.width/2;
self.portraitImageView.layer.masksToBounds = YES;
//自定义动画
self.backImage.transform = CGAffineTransformMakeScale(0.5, 0.5);
// 弹簧动画,参数分别为:时长,延时,弹性(越小弹性越大),初始速度
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.3 initialSpringVelocity:0.3 options:UIViewAnimationOptionLayoutSubviews animations:^{
self.backImage.transform = CGAffineTransformMakeScale(1, 1);
} completion:^(BOOL finished) {
}];
}
- (id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
if (self)
{
// self.bounds = CGRectMake(0.f, 0.f, kWidth, kHeight);
//
// self.portraitImageView = [[UIImageView alloc] initWithFrame:CGRectMake(kHoriMargin, kVertMargin, kPortraitWidth, kPortraitHeight)];
self.portraitImageView = [UIImageView new];
self.backImage = [UIImageView new];
[_backImage addSubview:_portraitImageView];
[_backImage setImage:[UIImage imageNamed:@"icon_home_page_orientation"]];
[self addSubview:_backImage];
}
return self;
}
@end