当我尝试使用以下代码绘制如下形状时,形状仅显示半笔划线。
require 'watir'
browser = Watir::Browser.new
browser.goto('https://tripadvisor.com/CheapFlightsHome')
browser.text_field(name: 'orig').set('Boston, MA - Logan International Airport (BOS)')
browser.text_field(name: 'dest').set('Milan, Italy - All Airports (MIL)')
browser.execute_script('document.querySelector(".in_date").click()')
browser.execute_script('document.querySelector(".day_28").click()')
browser.execute_script('document.querySelector(".out_date").click()')
browser.execute_script('document.querySelector(".day_2").click()')
browser.span(id: "CHECK_FARES_BUTTON").fire_event :click
puts browser.url
browser.quit
=> https://www.tripadvisor.com/CheapFlightsSearchResults-g187849-a_airport0.BOS-a_airport1.MIL-a_cos.0-a_date0.20170328-a_date1.20170402-a_nearby0.no-a_nearby1.no-a_nonstop.no-a_pax0.a-a_travelers.1-Milan_Lombardy.html
创建形状:
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
如果我将x设置为10,它会显示另一半的stroe线,但形状没有关闭。
let shape = SKShapeNode()
shape.path = createPointerPath().cgPath
shape.position = CGPoint(x: frame.midX, y: frame.midY)
shape.fillColor = UIColor(red: 1.0, green: 0.439, blue: 0.678, alpha: 1.0)
shape.strokeColor = .white
shape.lineWidth = 2
addChild(shape)
有什么建议吗? THX!
答案 0 :(得分:1)
这是我尝试后得到的;希望它可以帮到你
let v : UIView = UIView.init(frame: CGRect.init(x: 50, y: 50, width: 200, height: 200))
v.layer.borderWidth = 2.0
let shape = CAShapeLayer()
shape.path = createPointerPath().cgPath
shape.position = CGPoint(x: frame.midX, y: frame.midY)
shape.fillColor = UIColor(red: 1.0, green: 0.439, blue: 0.678, alpha: 1.0).cgColor
shape.strokeColor = UIColor.white.cgColor
shape.lineWidth = 2
v.layer.addSublayer(shape)
self.addSubview(v)
你给的是同样的功能:
func createPointerPath() -> UIBezierPath {
let pointerPath = UIBezierPath()
pointerPath.move(to: CGPoint(x:0, y:0))
pointerPath.addCurve(to: CGPoint(x:0, y:100), controlPoint1: CGPoint(x:-10, y:0), controlPoint2: CGPoint(x:-50, y:100))
pointerPath.addCurve(to: CGPoint(x:0, y:0), controlPoint1: CGPoint(x:50, y:100), controlPoint2: CGPoint(x:10, y:0))
pointerPath.stroke()
pointerPath.close()
return pointerPath
}
输出: