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

Unicode not working properly in iOS
Selecting a word and shows tooltip in iOS
UIBarButtonIteem common to all controllers
App ID Prefix at apple developer
What happens if I use accessibilityIdentifier and accessibilityLabel on same element
Migrating my app to 64 bit with parse and I get this link error that is driving me crazy
Calculating distance between two PFGeoPoints in Swift
Why isn't func motionEnded not working in GameScene?
moving UINavigationBar frame causes unrecognizable clicks
Why is (form.$error && form.$submitted) true on start?
How to keep objects in NSMutableArray?
Parse::UserCannotBeAlteredWithoutSessionError 206 iOS
iOS - How to Control the Kind of Animation in an Unwind Segue?
Flurry Ads Not Showing Up
UICollectionview cellForItemAtIndexPath not getting called when reload in iOS 8
Subviews in UITableViewCell's containView are not added into the UI hierarchy in iOS9

Categories

HOME
asp.net-identity
logstash
music
vr
auth0
jsessionid
intel-xdk
spi
autofac
h2o
silverlight
overloading
jquery-jtable
pyfftw
orchardcms-1.10
spring-cloud-consul
countdown
pywin32
aerospike
stm32f4discovery
revitpythonshell
deadbolt
centroid
google-distancematrix-api
c-strings
jsgrid
zos
confidence-interval
code-signing
arduino-esp8266
gcp
akka-http
json-c
scatter-plot
google-shared-contacts
chamilo-lms
ulimit
using
monogame
backwards-compatibility
integer-programming
invalidate
android-calendar
ctl
fido
libev
sshd
android-identifiers
biological-neural-network
django-errors
gwt-material-design
angular2-rc5
sound-synthesis
measurement-protocol
ubuntu-15.04
printscreen
balsamiq
finalcut
oracle-policy-automation
uploadify
js-of-ocaml
android-listfragment
base-conversion
abort
android-print-framework
size-t
min3d
reactive-cocoa-3
citymaps
xacml3
fig
hobbitmon
deepzoom
android-c2dm
visual-assist
chromeless
speaker
impdp
rpn
arr
force.com
objcopy
treetop
nstreecontroller
xoom
high-traffic
ryz
maemo
time-estimation
posterous

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