jjzjj

ios - UIBezierPath 段连接导致间隙

coder 2024-01-18 原文

我正在使用 [SKShapeNode shapeNodeWithPath...],但无论我为线连接、平坦度或 miterLimit 设置了哪个选项,我在绘制线时都会出现间隙。为什么会这样?

UIBezierPath* bezierPath = UIBezierPath.bezierPath;
[bezierPath moveToPoint: CGPointMake(43.5, 49.5)];
[bezierPath addLineToPoint: CGPointMake(273.5, 49.5)];
[bezierPath addCurveToPoint: CGPointMake(273.5, 116.5) controlPoint1: CGPointMake(273.5, 49.5) controlPoint2: CGPointMake(322.5, 82.5)];
[bezierPath addCurveToPoint: CGPointMake(287.5, 222.5) controlPoint1: CGPointMake(224.5, 150.5) controlPoint2: CGPointMake(287.5, 222.5)];
[bezierPath addCurveToPoint: CGPointMake(227.5, 294.5) controlPoint1: CGPointMake(287.5, 222.5) controlPoint2: CGPointMake(351.5, 316.5)];
[bezierPath addCurveToPoint: CGPointMake(43.5, 255.5) controlPoint1: CGPointMake(103.5, 272.5) controlPoint2: CGPointMake(43.5, 255.5)];
[bezierPath addCurveToPoint: CGPointMake(43.5, 181.5) controlPoint1: CGPointMake(43.5, 255.5) controlPoint2: CGPointMake(-38.5, 221.5)];
[bezierPath addCurveToPoint: CGPointMake(171.5, 181.5) controlPoint1: CGPointMake(125.5, 141.5) controlPoint2: CGPointMake(171.5, 164.5)];
[bezierPath addCurveToPoint: CGPointMake(123.5, 203.5) controlPoint1: CGPointMake(171.5, 198.5) controlPoint2: CGPointMake(160.5, 225.5)];
[bezierPath addCurveToPoint: CGPointMake(54.5, 222.5) controlPoint1: CGPointMake(86.5, 181.5) controlPoint2: CGPointMake(54.5, 222.5)];
[bezierPath addCurveToPoint: CGPointMake(227.5, 255.5) controlPoint1: CGPointMake(54.5, 222.5) controlPoint2: CGPointMake(210.5, 277.5)];
[bezierPath addCurveToPoint: CGPointMake(227.5, 181.5) controlPoint1: CGPointMake(244.5, 233.5) controlPoint2: CGPointMake(227.5, 181.5)];
[bezierPath addCurveToPoint: CGPointMake(227.5, 116.5) controlPoint1: CGPointMake(227.5, 181.5) controlPoint2: CGPointMake(206.5, 142.5)];
[bezierPath addCurveToPoint: CGPointMake(227.5, 88.5) controlPoint1: CGPointMake(248.5, 90.5) controlPoint2: CGPointMake(227.5, 88.5)];
[bezierPath addLineToPoint: CGPointMake(43.5, 88.5)];
[bezierPath addLineToPoint: CGPointMake(43.5, 49.5)];
[bezierPath closePath];

CGFloat scale = 4;
[bezierPath applyTransform:CGAffineTransformMakeScale(scale, scale)];

最佳答案

来自docs

A line width larger than 2.0 may cause rendering artifacts in the final rendered image. The default value is 1.0.

改变线宽可能会有帮助。然而,使用 UIKIT 肯定不会导致任何缺陷。我想知道你是否可以切换到那个。

另一个有趣的读物: http://sartak.org/2014/03/skshapenode-you-are-dead-to-me.html

关于ios - UIBezierPath 段连接导致间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31039696/

有关ios - UIBezierPath 段连接导致间隙的更多相关文章

  1. ruby - 续集在添加关联时访问many_to_many连接表 - 2

    我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以

  2. ruby - 无法在 60 秒内获得稳定的 Firefox 连接 (127.0.0.1 :7055) - 2

    我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类

  3. ruby - 如何验证 IO.copy_stream 是否成功 - 2

    这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下

  4. Ruby 文件 IO 定界符? - 2

    我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的

  5. Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting - 2

    1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里

  6. Ruby 守护进程导致 ActiveRecord 记录器 IOError - 2

    我目前正在用Ruby编写一个项目,它使用ActiveRecordgem进行数据库交互,我正在尝试使用ActiveRecord::Base.logger记录所有数据库事件具有以下代码的属性ActiveRecord::Base.logger=Logger.new(File.open('logs/database.log','a'))这适用于迁移等(出于某种原因似乎需要启用日志记录,因为它在禁用时会出现NilClass错误)但是当我尝试运行包含调用ActiveRecord对象的线程守护程序的项目时脚本失败并出现以下错误/System/Library/Frameworks/Ruby.frame

  7. ruby - 我的 Ruby IRC 机器人没有连接到 IRC 服务器。我究竟做错了什么? - 2

    require"socket"server="irc.rizon.net"port="6667"nick="RubyIRCBot"channel="#0x40"s=TCPSocket.open(server,port)s.print("USERTesting",0)s.print("NICK#{nick}",0)s.print("JOIN#{channel}",0)这个IRC机器人没有连接到IRC服务器,我做错了什么? 最佳答案 失败并显示此消息::irc.shakeababy.net461*USER:Notenoughparame

  8. ruby - 为什么不能使用类IO的实例方法noecho? - 2

    print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上

  9. ruby-on-rails - 连接字符串时如何在 <%=%> block 内输出 html_safe? - 2

    考虑一下:现在这些情况:#output:http://domain.com/?foo=1&bar=2#output:http://domain.com/?foo=1&bar=2#output:http://domain.com/?foo=1&bar=2#output:http://domain.com/?foo=1&bar=2我需要用其他字符串输出URL。我如何保证&符号不会被转义?由于我无法控制的原因,我无法发送&。求助!把我的头发拉到这里:\编辑:为了澄清,我实际上有一个像这样的数组:@images=[{:id=>"fooid",:url=>"http://

  10. ruby - 从另一个私有(private)方法中使用 self.xxx() 调用私有(private)方法 xxx,导致错误 "private method ` xxx' called” - 2

    我正在尝试获得良好的Ruby编码风格。为防止意外调用具有相同名称的局部变量,我总是在适当的地方使用self.。但是现在我偶然发现了这个:classMyClass上面的代码导致错误privatemethodsanitize_namecalled但是当删除self.并仅使用sanitize_name时,它会起作用。这是为什么? 最佳答案 发生这种情况是因为无法使用显式接收器调用私有(private)方法,并且说self.sanitize_name是显式指定应该接收sanitize_name的对象(self),而不是依赖于隐式接收器(也是

随机推荐