let path = UIBezierPath()
shapeLayer.strokeColor = UIColor.blue.cgColor
shapeLayer.lineWidth = 3
path.move(to: startPoint)
path.addLine(to: point)
shapeLayer.lineJoin = kCALineJoinRound
shapeLayer.path = path.cgPath
tempImage.layer.addSublayer(shapeLayer)
我正在使用上面的代码。每次调用上面的代码都会移动触摸。我没有连续画画。只有我的绘画的最后部分是可见的。这里有我遗漏的任何东西。
答案 0 :(得分:0)
我使用add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 );
function add_order_email_instructions( $order, $sent_to_admin ) {
if ( ! $sent_to_admin ) {
if ( 'cod' == $order->payment_method ){
// cash on delivery method
echo '<p><strong>Please note: </strong>Your repair is currently pending acceptance from your local technician. A member of our team will contact you shortly.</p>';
}
else if( is_category_in_order($order, 'unlocking') ){
// unlocking email
echo '<p>Your device should be unlocked within 48 hours, if your device requires an unlock code we will be in touch.</p>';
}
else {
// other methods (ie credit card)
echo '<p><strong>Instructions:</strong> Please ensure your device is packaged securely and send it to the following address:</p><br><br><p><strong>Please note; if using our Unlocking service, you do NOT need to send us your device.</strong></p>';
}
}
}
/* Check if order contains a product from a specific category */
function is_category_in_order($order, $target_category) {
// initialize variable for if category exists in order
$category_present = false;
// get the items array from the order object
$items = $order->get_items();
// loop through the items in the order
foreach ( $items as $item ) {
// get the product ID of the current item
$pid = $item->get_product_id();
// check if product has target category
if ( has_term( $target_category, 'product_cat', $pid ) ) {
// if so, set our category exists in order variable to true
$category_present = true;
break;
}
}
return $category_present;
}
和UIBezierPath
进行了平滑绘制。这里的方法是使用临时的贝塞尔曲线路径。
如果您想在图像上绘制图像,则可以尝试使用类似CAShapeLayer
的方法。
快捷键4
drawingLayer.content = yourImage.cgImage