简体   繁体   English

画圆角框

[英]Draw round-corner box

In my application I have a map, this map has a lot of annotations... but sometimes no location is found for an annotation (server couldn't find lat/lon). 在我的应用程序中,我有一个地图,该地图有很多注释...但是有时找不到注释的位置(服务器找不到经纬度)。 When this happens, I would like to draw a little box on my map with the text "Some locations could not be found" (or similar). 发生这种情况时,我想在地图上画一个小框,上面写着“找不到某些位置”(或类似内容)。 I want this box to have round corners and to be transperant. 我希望这个盒子有圆角并且是透明的。 Also, if possible I would prefer if this does not effect the functionality of the map. 另外,如果可能的话,我希望它不会影响地图的功能。 What I mean with that is that if the user draws its finger on the map from where that box is located, the map should still move. 我的意思是,如果用户在该框所在的位置上将手指放在地图上,则地图仍应移动。

How can I make such a box? 我该如何做一个盒子?

This is what I mean: 这就是我的意思:
替代文字

Best regards, 最好的祝福,
Paul Peelen 保罗·皮伦

Either use Photoshop :), or else do it using CALayer. 使用Photoshop :),或使用CALayer。

To do it with a layer, create a UIView called bgView with the appropriate alpha value for your background and then do this in the method where you want to display the alert panel:- 要对图层进行处理,请创建一个名为bgView的UIView,并为其背景设置适当的alpha值,然后在要显示警报面板的方法中执行此操作:

CALayer *layer = bgView.layer;
layer.masksToBounds = YES;
layer.cornerRadius = 20.0; // adjust for corner effect

There is some demo code at: http://www.eng.utah.edu/~cs4962/programming.html 在以下位置有一些演示代码: http : //www.eng.utah.edu/~cs4962/programming.html

In the solution for the color chooser. 在颜色选择器的解决方案中。 (In the top section) (在顶部)


+ (void) addRoundedRect:(CGRect)rect radiusPercent:(float)radiusPercent
{
    CGContextRef context = UIGraphicsGetCurrentContext();

CGFloat radius = fminf(rect.size.width, rect.size.height) * radiusPercent; CGFloat minX = CGRectGetMinX(rect); CGFloat midX = CGRectGetMidX(rect); CGFloat maxX = CGRectGetMaxX(rect); CGFloat minY = CGRectGetMinY(rect); CGFloat midY = CGRectGetMidY(rect); CGFloat maxY = CGRectGetMaxY(rect); CGContextMoveToPoint(context, minX, midY); CGContextAddArcToPoint(context, minX, minY, midX, minY, radius); CGContextAddArcToPoint(context, maxX, minY, maxX, midY, radius); CGContextAddArcToPoint(context, maxX, maxY, midX, maxY, radius); CGContextAddArcToPoint(context, minX, maxY, minX, midY, radius); CGContextClosePath(context);

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM