Is it possible to have a curve UISlider or is it just Horizontal and Vertical?
I've tried replacing the slider track with a curve image (though i already know hat it will not work because it is just a background), not working.
Is there a way that i could do that?
Take a look at custom controls (both of them are under MIT license):
MHRotaryKnob
Cocoacontrols
Github
DCKnob
Cocoacontrols
Github
I wrote this sample app to show how to use a Curve UIBezierPath and move an object through it
you can take a look at :
Curvy UISlider
I will try to update it.
No you can't do this with the UISlider, only in a straight line. You can rotate the whole slider to a degree you like with the transform property and use a function like CGAffineTransformMakeRotation. An example: How to use CGAffineTransformMakeRotation?.
You can also check out BezierSlider which allows you to customize the path and the selector.
Related
Very excited for my first post on SO!
I would like to create an animation like this in xcode
I am not having much luck with what CABasicAnimation has to offer.
Feels like I may need one of those fancy physics engines...(?)
How would one properly begin do this?
Thanks!
I would probably use NSBezierPath to create such an animation. I would create a path which I extended along the sine curve on each iteration, and stroke the path appropriately. If you give us more details about what you're attempting to do, we can give you more details about how to do it.
Exactly what you want.TFAnimation allows you to use customize timingFunction by set a closure to timeFunction of TFBasicAnimation.
The demo in github is exactly a Sin animation.It use a CAAnimationGroup combined linear CABasicAnimation in position x and TFBasicAnimation of Sin timeFunction in position y.
I have been looking for the solution on the web for a long time. Most tutorials are fairly simple about adding shadow to a UIView. I also noticed that if we add a shadow to an UIImageView. The shadow shape could perfectly fit the shape of the content image if the image itself has alpha channel in it. Say for example, if the image is an animal with transparent background, the shadow shape is also the same as that animal (not a rectangle shadow as same as UIImageView frame).
But these are not enough. What I need to do is to add some changes to the shadow so it may have some rotation angle and compressed (squeezed or shift) effect so that looks like the sunlight comes from a certain spot.
To demonstrate what I need, I upload 2 images below, which I captured from the Google Map App created by Apple. You can imagine the Annotation Pin is an image which has the Pin shape, so the shadow is also "pin shaped", but it is not simply "offset" with a CGSize, you can see the top of the shadow is shifted right about 35 degrees and slightly squeezed the height.
When we tap and hold and pin, the shadow is also animated away from the pin, so I believe that such shadow can be made programmably.
The best shadow tutorial I can found so far is http://nachbaur.com/blog/fun-shadow-effects-using-custom-calayer-shadowpaths But unfortunately, that cannot make this effect.
If anyone know the answer or know any better words to search for, please let me know. Thank you.
(Please note that the shape of the image is dynamic in the App, so using any tool like Photoshop to pre-render the shadow is not an option.)
In order to create dynamic effects like this, you have to use Core Graphics. It's incredibly powerful once you know how to use it. Basically you need to set a skew transform on the context, set up a shadow and draw the image. You will probably have to use transparency layers as well.
It doesn't sound like you can use CALayer shadows, since that is meant to solve a specific use-case. The approach Apple takes with the pin marks on the map is to have two separate images that are created ahead of time (e.g. in Photoshop) and they position them within the map relative to a reference point.
If you really do need to do this at run-time, it should still be possible by using either Core Graphics or ImageKit. To get a blurred shadow appearance, you can use the kCICategoryBlur CIFilter. You can then convert the image to grayscale. And to get that compressed look you just need to resize and skew the image.
Once you have two separate images, you can either take the CGImageRef for the shadow image and can set that as the content of another sublayer, or you can add it as a separate view.
If you know what all the shapes are, you could just render a shadow image in Photoshop or something.
Notice this app:
How can I draw that sort of triangle above an existing NSWindow? I know the app in question probably draws the whole thing as a custom window, but I want to keep the existing title bar. Is there any way to draw a triangle and attach it above a NSWindow? Please note that the solution has to be MAS-compatible (i.e. no private frameworks or classes).
The only way to do this would be to create a borderless child window with no shadow that overlays the edge of the existing window. You'd need to draw any shadow yourself.
A more comprehensive solution would involve subclassing NSThemeFrame and doing some custom drawing. Take a look at Matt Gallagher's Drawing a custom window on Mac OS X. It contains a wealth of helpful information, and Google will also be of great help here.
I've written an open source (BSD) framework that draws windows similar to this: https://github.com/sbooth/SFBPopovers
It won't directly do what you need but will illustrate the basics of drawing custom window frames.
This has already been asked at Add a magnifier in cocos2d games
But I didn't quite understand the answer. I am using the same tutorial Let's Spot It is using but I'm not sure where to put madhu's code. I also don't know what the runAction method looks like.
Thanks
Hmm... Cocos2d CCLens3D, makes the area that is set by the programmer to popup.. Please look at the example provided by cocos2d..
the codes:
id lens = [CCLens3D actionWithPosition:ccp(size.width/2,size.height/2) radius:240 grid:ccg(15,10) duration:0.0f];
[self runAction:lens];
self is the layer where your image should be..
ccp(size.width/2, size.height/2) should be changed to ccp(yourPosition.x, yourPosition.y), means the positions which you want the popUp to be at.. Radius is the size of the circle, duration is how long you want it to be, 0.0 meaning infinite.. grid just use the same values..
I'm working on an iPhone app that has some non-rectangular UI elements. Currently, I'm subclassing UIView, and in drawRect I'm using a CGPathRef to draw black border and a color-filled interior.
I'd like to make these items look more like "buttons", though, so I'd like to have some of the same sort of "glass effects" that are used on e.g. the icons for an iPhone app (when you don't set UIPrerenderedIcon to true), or in other buttons.
I hunted around, and found this, which seems to be close to what I need:
Gradients on UIView and UILabels On iPhone
But I'm having difficulty figuring out how to clip the gradient to my shape.
It seems like the mask property on the view would be the right place to go, which seems like it would call for me to create a new CALayer object, with the clipping somehow applied to it.
I'm hoping there's some nice convenience function for doing this, though if I need to write something more complicated, that's OK, too. I'm just having difficulty figuring out how to apply the path as a mask. I'm unsure if I need to create a new drawing context and draw the path into it? And then use CGContextClip?
I think I've got a lot of the right pieces figured out, I'm just having difficulty understanding how to assemble them.
Could someone please point me in the right direction? (I'm happy to read more in the docs, just point me in the right direction, please.)
You can create a CAShapeLayer and set its path to your CGPathRef. Then set the mask property of a CAGradientLayer to your shapeLayer.