I am developing an app which enable users to draw a connection between different components, I tried to use CGPath to draw a line. But the problem is, the line is not an object which I can not reference it later or edit it.
Since I want to enable the app to create a line when two points in screen is touched, and can delete it if need by touching the line, do you have any good ideas to implement this?
Thanks very much!
I think you're looking for CAShapeLayer. You can change its path property after it's been added to the layer hierarchy and it will update accordingly.
Related
now I am conducting a iOS app with objective-c. I need to have a process bar with stepping to indicate the user registration procedure. How can I do it as the pictures?
I have made a custom view to implement the step indicator. Use CAShapeLayer to draw the circle and line. Check detail here: https://github.com/chenyun122/StepIndicator
The effect is:
OR
If you want to replace the core point by number, you could folk this project and modify the class AnnularLayer.swift to implement that.
If animation doesn't matter then you can used image.Change your image when you push view
I am having a problem while using something like a DAScratchPad. I had this problem while drawing a line. The initial point is not moving properly and the below problem occurs when I draw the line for the first time:
In the above image I was trying to draw a straight line but after touches moved this happened. This also happens everytime after the orientation change.
Kindly help me to resolve this. Thanks in advance.
In Xcode 5, I am trying to make an app that allows the user to draw a line based on touch. I would have this working using UIBezierpath but then I am not able to remove the last line once the user tries to draw a new one. What method would I use to draw a line between touchDown and touchUp that can be easily deleted? Thanks in advance!
The easiest way is to use the UIBezierPath to construct a path which you then assign to a CAShapeLayer. You then add that layer as a sublayer to some view you already have in the interface. To delete the line, remove the layer.
I am trying to use SlidingMenuGrid code inside my app and changing a bit the beahaviour. The thing is I am a bit stuck. In Brandon Reynolds's blog you can find a sample project with the menu which is great. I am very greatful to him for sharing his useful code.
What I want to achieve is a sliding menu where not only the image item can be touched but also an image representing a button with the option to buy the product (or more buttons - example BUY/SELL - USE/STOP USING etc.. RPG Style). In the image below I used a menu item with text but in the final version I will want to use a Menu item with sprite.
SlidingMenuGrid works by accepting an array of CCMenuItemSprite and the API allows to set the display type, nr of columns and rows.
I have tried adding a CCMenu with a selector in the CCLayer where I also add the SlidingMenuGrid instance but unfortunately, even if I enable touches, the selector is never called when clicking on it.
I think that what is happening is that SlidingMenuGrid swallows all touches. I tried to modify it but I don't really understand the code and I was trying to find a simpler and easier solution (e.g. by adding a menu item on the Layer instead of playing with SlidingMenuGrid).
Any ideas or suggestions?
Some previous users have mentioned that they have added a "Back" button to the system by placing it on another layer and setting the menugrid to not swallow touches. I have not tested this but I would think it should work..
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:INT_MIN+1 swallowsTouches:NO]
See the rest of the comments on the post on my blog for maybe some further information.
-Brandon Reynolds
Thank you in advance for any help, I am building a multipage iPad app,and each page has specialized calculations, they all work great, but i would like to make the user experience better with some simple line drawings that represent the calculations, I am comfortable with the drawing once i get a valid CGcontext working, and this is where my problem is. I already have a webview on each page and now I want to have a UIView pop open with my drawing when the user presses the calculate button, My UIview is called drawingView and it will pop open like I want but from what i have read all drawing needs to be done within the DrawRect method in order to use the correct context. I think some of my problem is the syntax for getting the context.
Thanks for any help
Norman
Ok, I had to do what I wanted the old fashioned way, but it just seems like you should be able to get the current context of a UIView from wherever I want. By calling the view and getting it's current context. But when I do ,I get errors about not getting the current context. So, I have to make my app differently using traditional UIViews classes and bringing them into my page.