4灵迫、自定義BMKAnnotationView點擊沒有響應(yīng)的問題
3、數(shù)組越界導(dǎo)致崩潰竭翠,查找源頭
點擊debug->BreakPoints->Create Exception BreakPoints涎永,然后重新運行,斷點就停留在導(dǎo)致崩潰的地方
2诉濒、通過UIBezierPath來設(shè)置圓角
通過設(shè)置圓角周伦,一般會這樣用:
self.button.layer.cornerRadius = self.button.frame.size.height / 2.0;
self.button.clipsToBounds = YES;
但要設(shè)置下圖這樣的圓角方式夕春,上面的方法就不行了
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;
其中,這些可以根據(jù)需要設(shè)置
UIRectCornerTopLeft? ? = 1 << 0,
UIRectCornerTopRight? ? = 1 << 1,
UIRectCornerBottomLeft? = 1 << 2,
UIRectCornerBottomRight = 1 << 3,
UIRectCornerAllCorners
1专挪、調(diào)整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];