In CABasicAnimation.fromValue
I want to convert a CGPoint
to a "class" so I used NSValue
valueWithPoint
but in device mode or simulator one is not working...
need to use NSMakePoint
or CGPointMake
if in device or simulator.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- back button text does not change
相关文章
- 现在使用swift开发ios应用好还是swift?
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
&(cgpoint) -> get a reference (address) to cgpoint (NSPoint *)&(cgpoint) -> casts that reference to an NSPoint pointer *(NSPoint )(cgpoint) -> dereferences that NSPoint pointer to return an NSPoint to make the return type happy
@ashcatch 's answer is very helpful, but consider that those methods from addition copy values, when native
NSValue
methods store pointers! Here is my code checking it:here
newPoint.x = 2; point.x = 10
here
newPoint.x = 10; point.x = 10
In Swift, you can change a value like this:
There is a
UIKit
addition toNSValue
that defines a functionSee iPhone doc
In Swift the static method is change to an initialiser method:
Don't think of it as "converting" your point-- NSValue is a wrapper class that holds primitive structs like NSPoint. Anyway, here's the function you need. It's part of Cocoa, but not Cocoa Touch. You can add the entire function to your project, or just do the same conversion wherever you need it.