ios


How to set the property for each “subUIBezierPath”


Problem description
I'm trying to add a "gesture unlock" function in my app but I have a problem as shown in the attached image. I found some unnecessary lines also draw out. In fact, I just need to show out the line to connect each "buttons".
Please check the image below
Below is my Code under - (void)drawRect:(CGRect)rect
// Main Path
UIBezierPath *path = [UIBezierPath bezierPath];
// Rect path
UIBezierPath *rectPath = [UIBezierPath bezierPathWithRect:rect];
[path appendPath:rectPath];
// 9 circle path
[self.subviews enumerateObjectsUsingBlock:^(PPSingleCircle * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIBezierPath *circlePath = [UIBezierPath bezierPathWithOvalInRect:obj.frame];
[path appendPath:circlePath];
}];
// clip the path
path.usesEvenOddFillRule = YES;
[path addClip];
// add line to each select Views
for (int i = 0; i < [self.selectViews count]; i++) {
PPSingleCircle *singleView = self.selectViews[i];
if (i == 0) {
[path moveToPoint:singleView.center];
}else {
[path addLineToPoint:singleView.center];
}
}
// add line to current point
[path addLineToPoint:self.currentPoint];
// set display style
[kLineColor setStroke];
path.lineWidth = kLineWidth;
path.lineJoinStyle = kCGLineJoinRound;
path.lineCapStyle = kCGLineCapRound;
[path stroke];
I fix the issue as below
// Main Path
UIBezierPath *path = [UIBezierPath bezierPath];
// Line Path
UIBezierPath *linePath = [UIBezierPath bezierPath];
// Rect path
UIBezierPath *rectPath = [UIBezierPath bezierPathWithRect:rect];
[path appendPath:rectPath];
// 9 circle path
[self.subviews enumerateObjectsUsingBlock:^(PPSingleCircle * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIBezierPath *circlePath = [UIBezierPath bezierPathWithOvalInRect:obj.frame];
[path appendPath:circlePath];
}];
// clip the path
path.usesEvenOddFillRule = YES;
[path addClip];
// stroke the "Main path" first
[path stroke];
// add line to each select Views
for (int i = 0; i < [self.selectViews count]; i++) {
PPSingleCircle *singleView = self.selectViews[i];
if (i == 0) {
[linePath moveToPoint:singleView.center];
}else {
[linePath addLineToPoint:singleView.center];
}
}
// add line to current point
PPSingleCircle *view = self.selectViews[0];
if (view.status != CircleStatusError) {
[linePath addLineToPoint:self.currentPoint];
}
// set display style
[kLineColor setStroke];
linePath.lineWidth = kLineWidth;
linePath.lineJoinStyle = kCGLineJoinRound;
linePath.lineCapStyle = kCGLineCapRound;
// add line path and draw
[linePath stroke];

Related Links

How to crop my App image like iPhone photo gallary
iOS: How to subscribe a customer to an Automatically Renewable Subscription
Add objects into array from UITableViewCell
Moving view closer to camera
My session.dataTaskWithRequest method is not returning any data
How to fetch all WiFi connection
Swift 2 Static UICollectionView change to Json Parsing UICollectionView
MyApp-Swift.h file not found. for a specific class only
Realm- updating all items in array of objects instead of appending only new one
Show Interstitial In Other Scenes - Admob, SpriteKit, Swift
Control table views inside a single collection view cell
Set CheckBox on - off
Custom Class View for UIButton
dispatch task into queue in order to run the task in another thread [duplicate]
How to compare PHAsset to UIImage
compiler error use custom shader on a geometry

Categories

HOME
ios
ssis
mocking
web-applications
clojure
music
openshift-origin
apt-get
load
python-3.5
applet
robot
weblogic11g
openvpn
application-cache
splunk
add-in
square-connect
light-inject
pymc3
proftpd
scrollbar
reload
lighttpd
asp.net-mvc-5.2
thrift
gitlab-ci-runner
gyroscope
media-source
jpos
haml
realm-java
opencms
stylesheet
mathdotnet
esri
codewarrior
valueinjecter
debugview
toastr
svgpanzoom
photo-gallery
doctrine-odm
fipy
nav
folly
xaf
kmdf
cookiestore
otroslogviewer
drupal-webform
essbase
automata-theory
formatdatetime
quicksand
sections
mrtg
dump
ios-app-group
replaygain
ternary
soql
g-wan
fasta
javascript-security
tastypie
callkit
mysql-notifier
cakephp-2.3
evaluate
git-config
xpdf
ellipsis
geneos
activemodel
enhanced-ecommerce
target-platform
subroutine
domo
par
spymemcached
maven-cargo
pegkit
mks
kue
esx
knockout-mvc
express-jwt
textselection
wmv
grunt-contrib-copy
css3pie
disabled-input
vlfeat
gigaspaces
google-website-optimizer
oledbcommand
ms-access-97
proxy-classes
sdl.net
servletunit
renderaction
symstore
automapping
project-settings

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App