一些零碎的笔记

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];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容