4、自定義BMKAnnotationView點擊沒有響應的問題
3、數組越界導致崩潰,查找源頭
點擊debug->BreakPoints->Create Exception BreakPoints,然后重新運行,斷點就停留在導致崩潰的地方
2、通過UIBezierPath來設置圓角
通過設置圓角,一般會這樣用:
self.button.layer.cornerRadius = self.button.frame.size.height / 2.0;
self.button.clipsToBounds = YES;
但要設置下圖這樣的圓角方式,上面的方法就不行了
UIBezierPath *maskPath =[UIBezierPath bezierPathWithRoundedRect:self.button.bounds byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(self.button.bounds.size.height/2, self.button.bounds.size.height/2)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.button.bounds;
maskLayer.path = maskPath.CGPath;
self.button.layer.mask = maskLayer;
其中,這些可以根據需要設置
UIRectCornerTopLeft? ? = 1 << 0,
UIRectCornerTopRight? ? = 1 << 1,
UIRectCornerBottomLeft? = 1 << 2,
UIRectCornerBottomRight = 1 << 3,
UIRectCornerAllCorners
1、調整leftBarItem的點擊范圍
自定義一個Button,將這個Button加入到View中,再將View添加到leftBarItem里面。
UIButton*closeBtn = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
[closeBtnsetImage:[UIImageimageNamed:@"publish_close"]forState:UIControlStateNormal];
[closeBtnaddTarget:selfaction:@selector(closeAction)forControlEvents:UIControlEventTouchUpInside];
closeBtn.frame=CGRectMake(0,0,44,44);
UIView*leftBackBtnView = [[UIViewalloc]initWithFrame:closeBtn.bounds];
leftBackBtnView.bounds=CGRectOffset(leftBackBtnView.bounds,10,0);
[leftBackBtnViewaddSubview:closeBtn];
self.navigationItem.leftBarButtonItem= [[UIBarButtonItemalloc]initWithCustomView:leftBackBtnView];