我试图在UIImageView上绘图.使用Swift 1.2我能够让它工作,但我不得不将它转换为swift 3.0而我无法让它工作.
它需要做的是用手指准确地绘制你在屏幕上绘制的内容.
代码没有错误,但只是没有显示任何内容.
变量;
var lastPoint = CGPoint.zero
var red: CGFloat = 0.0
var green: CGFloat = 0.0
var blue: CGFloat = 0.0
var brushWidth: CGFloat = 10.0
var opacity: CGFloat = 1.0
var swiped = false
Run Code Online (Sandbox Code Playgroud)
代码;
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
swiped = false
if let touch = touches.first {
lastPoint = touch.location(in: self.view)
}
}
func drawLineFrom(fromPoint: CGPoint, toPoint: CGPoint) {
imageView.image?.draw(in: CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height))
UIGraphicsBeginImageContext(self.imageView.bounds.size); …Run Code Online (Sandbox Code Playgroud) 我有一些输出json的PHP.
<?php
$html = utf8_encode($gegevens['tekst']);
$html = htmlentities($html);
//$html = htmlspecialchars($gegevens['tekst'], ENT_QUOTES, 'UTF-8');
echo json_encode(array( 'titel' => $gegevens['titel'], 'html' => $html ));
?>
Run Code Online (Sandbox Code Playgroud)
输出将如下:
{"titel":"Here comes the title","html":"<strong>Here is the HTML<\/strong>\n<br \/>\n<br \/>\n And some more."}
Run Code Online (Sandbox Code Playgroud)
而jQuery/Ajax将是:
$.ajax({
type: "GET",
url: "content/popup.php?id=" + id2,
dataType: 'json',
crossDomain: true,
success: function(json) {
var titel = json['titel'];
var html = json['html'];
function ContentTonen()
{
// Div's legen van content
$('.popup_home_head_inside').empty();
$('.popup_home_content_inside').empty();
$('.popup_home_head_inside').html(titel);
var html2 = html.replace(/\"/g, "");
//$('.popup_home_content_inside').html(html2);
$('.popup_home_content_inside').html(html2);
Run Code Online (Sandbox Code Playgroud)
HTML输出是:
<strong>Some HTML</strong> …Run Code Online (Sandbox Code Playgroud) 谁能告诉我发生了什么事?
包括AFnetworking后我得到9个错误,见下文.

