override func drawInContext(ctx: CGContext) {
if let slider = slider {
// Clip
let rect = bounds.insetBy(dx: bounds.width / 10, dy: bounds.height / 2.2)
let path = UIBezierPath(roundedRect: rect, cornerRadius: 5)
let circleRadius : CGFloat = 10
let xCoordInset = bounds.width / 10
let circlePath = UIBezierPath(ovalInRect: CGRectMake(xCoordInset , rect.midY - circleRadius, circleRadius * 2, circleRadius * 2))
let circlePath1 = UIBezierPath(ovalInRect: CGRectMake(bounds.width - xCoordInset - circleRadius, rect.midY - circleRadius, circleRadius * 2, circleRadius * 2))
let circlePath2 = UIBezierPath(ovalInRect: CGRectMake(rect.midX - circleRadius, rect.midY - circleRadius, circleRadius * 2, circleRadius * 2))
path.appendPath(circlePath)
path.appendPath(circlePath1)
path.appendPath(circlePath2)
let yCut = bounds.midY // or whatever
CGContextSaveGState(ctx); do {
CGContextClipToRect(ctx, CGRectMake(bounds.minX, bounds.minY, bounds.width, yCut - bounds.minY))
CGContextAddPath(ctx, path.CGPath)
CGContextSetFillColorWithColor(ctx, slider.trackTintColor.CGColor)
CGContextFillPath(ctx)
}; CGContextRestoreGState(ctx)
CGContextSaveGState(ctx); do {
CGContextClipToRect(ctx, CGRectMake(bounds.minX, yCut, bounds.width, bounds.maxY - yCut))
CGContextAddPath(ctx, path.CGPath)
CGContextSetFillColorWithColor(ctx, slider.progressTintColor.CGColor)
CGContextFillPath(ctx)
}; CGContextRestoreGState(ctx)
}
}
我想将变量count的值插入数据库..是否可能?
答案 0 :(得分:0)
这是您的答案 - 这是一个更详细的解释,说明如何使用帖子从javascript获取数据到您的数据库,或者到达您创建的端点,该端点将localStorage的值写入您的数据库。
关键是您需要使用客户端调用来编写服务器,这通常使用以下答案中描述的方法完成。如果没有,它应该通过找到与此相关的不同方法来帮助您更有效地搜索,这可能适合您。
How to pass data from Javascript to PHP and vice versa?
此代码可能有助于解释这个想法:
function result() {
var resultText = "your mark is " + (localStorage.getItem("count") || 0) + " from 9";
document.write(resultText);
// set the full text into the hidden field value, or just do .val(localStorage.getItem("count")) if you only want the count.
$("#hdnFieldName").val(resultText);
}
<input type="hidden" id="hdnFieldName" name="hdnFieldName" value="" />
<input type="submit" text="Submit button" onclick="result();" />