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.
81 lines
3.1 KiB
81 lines
3.1 KiB
1 year ago
|
//
|
||
|
// 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:@"默认用户头像"]];
|
||
|
}
|
||
|
|
||
|
-(void)setImageWithString:(NSString*)string{
|
||
|
[self.backImage setImage:[UIImage imageNamed:string]];
|
||
|
self.backImage.contentMode = UIViewContentModeScaleAspectFit;
|
||
|
}
|
||
|
-(void)setRadian:(double)radian{
|
||
|
self.transform = CGAffineTransformRotate(self.transform, radian);
|
||
|
}
|
||
|
-(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, 3, frame.size.width, frame.size.height);
|
||
|
self.backImage.contentMode = UIViewContentModeScaleAspectFit;
|
||
|
self.portraitImageView.frame = CGRectMake(4, 5, 32, 32);
|
||
|
//self.portraitImageView.frame = CGRectMake(0, 0, frame.size.width*2/3, frame.size.width*2/3);
|
||
|
//self.portraitImageView.center = CGPointMake(_backImage.center.x, _backImage.center.y-3);
|
||
|
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:@"宝贝-无头像"]];
|
||
|
[self addSubview:_backImage];
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
@end
|