国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

i OS開發:對MKMapView的性能優化

2019-11-02 14:18:28
字體:
來源:轉載
供稿:網友

   最近做的項目主要是LBS這塊 主打成員定位功能 我們的UI設計是這樣的

iOS開發:對MKMapView的性能優化 電腦高手

  乍一看上去是挺好挺美觀的 不同的人會顯示不同的頭像 可是當人扎堆的時候 問題就來了

  當人多的時候(例如上圖所示) 地圖滑動起來就能感覺到明顯頓卡 那種不流暢感能折磨死人 所以

小清新網名[www.la240.com/html2017/1/34/]
自然我們要解決這個問題(等等 先不要吐槽為什么不用地圖聚合 因為這已經是地圖放到最大了 聚合不適合這次的問題討論)

  分析

  首先看下我是怎么實現這個annotationView的 由于這個annotationsView是異形的(也就是無法通過設置圓角直接得到) 而且里面的圖片還因用戶而異 所以解決方案就是使用layer.mask來進行遮罩 代碼如下

  @implementation MMAnnotationView

  - (instancetype)initWithAnnotation:(id)annotation reuseIdentifier:(NSString *)reuseIdentifier

  {

  self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];

  if ( self )

  {

  self.frame = CGRectMake(0, 0, TRACK_ANNOTATION_SIZE.width, TRACK_ANNOTATION_SIZE.height);

  self.centerOffset = CGPointMake(0, -(TRACK_ANNOTATION_SIZE.height-3)/2);

  self.canShowCallout = NO;

  self.avatarView = [[UIImageView alloc] initWithFrame:self.bounds];

  [self addSubview:self.avatarView];

  self.avatarView.contentMode = UIViewContentModeScaleAspectFill;

  CAShapeLayer *shapelayer = [CAShapeLayer layer];

  shapelayer.frame = self.bounds;

  shapelayer.path = self.framePath.CGPath;

  self.avatarView.layer.mask = shapelayer;

  self.layer.shadowPath = self.framePath.CGPath;

  self.layer.shadowRadius = 1.0f;

  self.layer.shadowColor = [UIColor colorWithHex:0x666666FF].CGColor;

  self.layer.shadowOpacity = 1.0f;

  self.layer.shadowOffset = CGSizeMake(0, 0);

  self.layer.masksToBounds = NO;

  }

  return self;

  }

  //mask路徑

  - (UIBezierPath *)framePath

  {

  if ( !_framePath )

  {

  CGFloat arrowWidth = 14;

  CGMutablePathRef path = CGPathCreateMutable();

  CGRect rectangle = CGRectInset(CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetWidth(self.bounds)), 3,3);

  CGPoint p[3] = {

  {CGRectGetMidX(self.bounds)-arrowWidth/2, CGRectGetWidth(self.bounds)-6},

  {CGRectGetMidX(self.bounds)+arrowWidth/2, CGRectGetWidth(self.bounds)-6},

  {CGRectGetMidX(self.bounds), CGRectGetHeight(self.bounds)-4}

  };

  CGPathAddRoundedRect(path, NULL, rectangle, 5, 5);

  CGPathAddLines(path, NULL, p, 3);

  CGPathCloseSubpath(path);

  _framePath = [UIBezierPath bezierPathWithCGPath:path];

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 苏尼特左旗| 葫芦岛市| 龙南县| 噶尔县| 久治县| 汉源县| 虹口区| 通州市| 方山县| 益阳市| 英吉沙县| 宁津县| 白水县| 嘉定区| 新晃| 枣强县| 沅江市| 河南省| 襄汾县| 四平市| 乐安县| 天台县| 福州市| 林西县| 贺兰县| 东明县| 尉氏县| 来宾市| 昔阳县| 玉山县| 临武县| 垦利县| 正镶白旗| 剑阁县| 富源县| 商洛市| 阿荣旗| 宁海县| 闸北区| 博爱县| 登封市|