通过使用[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:],我可以创建一个圆形视图,如下所示:

我怎样才能从这一个(或其他方式)中减去另一条路径,以创建这样的路径:

我有什么方法可以做这样的事情吗?伪代码:
UIBezierPath *bigMaskPath = [UIBezierPath bezierPathWithRoundedRect:bigView.bounds
byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)
cornerRadii:CGSizeMake(18, 18)];
UIBezierPath *smallMaskPath = [UIBezierPath bezierPathWithRoundedRect:smalLView.bounds
byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)
cornerRadii:CGSizeMake(18, 18)];
UIBezierPath *finalPath = [UIBezierPath pathBySubtractingPath:smallMaskPath fromPath:bigMaskPath];
Run Code Online (Sandbox Code Playgroud) 我正在webview中加载一个url,其中包含HTML和javascript函数调用.现在我正在研究用户触摸webview中的提交按钮时它应该调用viewController中的任何方法.Webview应该加载url(webview委托)是一种方法,但有任何新的方法来获取知道什么时候webview调用javascript函数应该通知viewcontroller或触发视图控制器中的任何方法.
我不是在寻找这个我们需要的解决方案
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSLog(@"passed data from web view : %@",[[request URL] query]);
if([[[request URL] query] isEqualToString:@"clickedOnLineNo"])
{
//Do your action here
}
Run Code Online (Sandbox Code Playgroud)
我们必须从你的javascript方法导航到假URL,比如
window.location = "someLink://yourApp/form_Submitted:param1:param2:param3";
Run Code Online (Sandbox Code Playgroud)
点击按钮或您需要的操作.
但JavaScriptCore是否有任何新的可能性来实现同样的目标.
我正在使用copy(strokingWithWidth:lineCap:lineJoin:miterLimit:transform :)来偏移CGPath .问题是偏移路径引入了似乎是斜接连接的各种锯齿状线.将更改设置miterLimit为0无效,使用斜角线连接也没有任何区别.
在此图像中,有原始路径(在应用之前strokingWithWidth),使用斜接连接的偏移路径,以及使用斜角连接的偏移路径.为什么不使用斜角连接有什么影响?
使用斜接的代码(注意使用CGLineJoin.round产生相同的结果):
let pathOffset = path.copy(strokingWithWidth: 4.0,
lineCap: CGLineCap.butt,
lineJoin: CGLineJoin.miter,
miterLimit: 20.0)
context.saveGState()
context.setStrokeColor(UIColor.red.cgColor)
context.addPath(pathOffset)
context.strokePath()
context.restoreGState()
Run Code Online (Sandbox Code Playgroud)
使用斜角的代码:
let pathOffset = path.copy(strokingWithWidth: 4.0,
lineCap: CGLineCap.butt,
lineJoin: CGLineJoin.bevel,
miterLimit: 0.0)
context.saveGState()
context.setStrokeColor(UIColor.red.cgColor)
context.addPath(pathOffset)
context.strokePath()
context.restoreGState()
Run Code Online (Sandbox Code Playgroud) 最近我一直在考虑如何将复杂多边形转换为非复杂多边形.这是怎么做到的?
这是我想要做的事情:

当我完成时,我将最终使用JavaScript,但任何形式的解决方案都很好(语言,算法或简单的英语).
ios ×2
javascript ×2
objective-c ×2
cgpath ×1
geometry ×1
ios7 ×1
iphone ×1
polygon ×1
swift ×1
swift3 ×1
uibezierpath ×1