How can I draw a little triangle above the selected item in a UISegmentedControl? Does anyone know an open-source than extends it?
(if not - pointers of how to do it)
Design should look like (this is in the bottom of the screen)
I don't believe there's a native way to do that. You can either find a library that allows for it, but you can do it yourself fairly easily, which I recommend.
I can think of a few out of the box ways to approach it, here at the two I think worth mentioning off the bat:
1) Use UISegmentedControl with images. Make the segmented controller have a height that includes the triangle, and have an image for selected and normal states that shows what you want. The Normal states would have a rectangle of transparency on top, as wide as the entire image and as tall as the triangle. The selected image would include the triangle. Both images should end up the same width and height.
2) Subclass UISegmentedControl and do some custom drawing in drawRect:. You could draw the triangle outside (above) the bounds of the segmented controller, make sure to set the segmented controller's clipToBounds property to NO, as well as its layer's masksToBounds property.
If you'd like more help, or some other suggestions, just ask.
Related
Wondering if the above can be created using UISlider? If not, what other ways can this be accomplished?
You can set components of a UISlider, such as the currentThumbImage ( see: "Appearance of Sliders"1).
However, it is almost certainly easier to just re-implement a slider for this much customization. Simply use background UIImageView with the scale image, and then add a separate UIView (or UIImageView) for the arrow. Finally, attach a UIPanGestureRecognizer to the arrow view to allow a user translate the view vertically.
You can change a lot in the appearance of a UISlider like setting the thumb to a red arrow. You can also replace the background image with the inches ruler and with different rulers for the different device types and display sizes.
The one thing that I don't see is that you turn the slider to work vertically. I know them only working left to right.
If I'm right, your only chance is to have a ruler as background image and a view that contains the arrow and a label with the actual value. That whole view can be pawned and tapped using Gesture Listener.
well am trying to make this UI :
the above UI contains a ProgressView on UITableViewCell and the vertical line is a UIView (if i should use something else then a UIView for this vertical line then please do provide your suggestions ) well am stuck in moving this vertical line ? how can i place this line at the point where the bar is filled as shown in the image , if anybody knows then please let me it'll be so helpful for me
the pseudocode for what i need will be like
verticleLine.xAxisPostion = progressBar.progress.xAxis
Trying to think out of the box here: maybe you could use a UISlider instead with userInteractionEnabled set to false? With UISlider you can specify not only the track color, but also the thumb image (being a tiny plain grey vertical bar in your case).
To expand a little bit: you set the minimumTrackTintColor to green, the maximumTrackTintColor to red (or stretchable images for minimum/maximumTrackImage), minimumValue to 0, maximumValue to 1. Instead of progress you can now use value — and it should give you roughly the same behaviour with the thumb (grey bar) following the value.
the above UI contains a ProgressView
Don't use a UIProgressView. Just create your own self-drawing view that looks exactly the way you want it to. The view that you've designed — green to the left of the progress point, red to the right of the progress point, and a vertical line right at the progress point — is trivial to draw, and trivial to redraw when progress happens (i.e. when the value changes).
There are a lot of questions about how to draw a drop shadow for a view. But how can I have my view cast a shadow that is received only by one other view?
If view A is the view with the shadow and view B is the parent of A, you can set masksToBounds which is a property of B's layer to YES.
Contents of B and its subviews will not be shown outside of B. They will be clipped.
More detail here: What UIView layer.masksToBounds is doing if set to YES?
However, if you want the shadow drops on more complex scene, you might need to be a little more specific.
Make an app with a white background.
Make your view plus shadow.
Take a screen shot.
Use the screen shot in your original app.
Of course you could also make the picture on the fly in code, but that is a bit more challenging. In any case, it would be code you do not need in your final app.
I have a UIScrollView over an image at the bottom of my app that acts as a dock with icons that can be scrolled through horizontally. Instead of the harsh edges of the UIScrollView, I would like the icons to fade out for a more aesthetically pleasing look. Being new to iOS development, I don't know if either of these would be valid options:
Create a faded image to use as an overlay on the scrollview so the
icons only appear through the visible portion.
Actually change the
alpha of the images based on their distance from the center (or from
each edge).
I suspect the first idea would be the most simple, but I'd like to throw this out there for any other ideas.
Note: I did see this tutorial, however that technique assumes that the background is a solid color. If I were to do it programatically, I would probably need to fade the individual images.
You can definitely implement something along the lines of #2. It'd be something similar to what the tutorial describes. The alpha transition however won't be as smooth as using the gradient layer mentioned in the tutorial or using an image since the entire icon would have the same alpha. How much discernible the difference is depends on the size of your icons. Smaller icons, very few will be able to tell the difference. Larger icons the difference would be quite clear.
You'd have to implement the
(void)scrollViewDidScroll:(UIScrollView *)scrollView
method in your scroll view's delegate class. This method will get called every time the scroll view changes the location of its content. In this method you can call its subviews and adjust their alphas as required. To optimize it a bit instead of calling the alpha adjustments on all the elements you can just update the subviews which are still partially/completely visible.
EDIT: to figure out which views to adjust you'll use the contentOffset property of the scrollView that gets passed as a parameter in the above method.
I want to design a UIButton in a specific way and cannot find in the Interface Builder all the relevant tools required for the design.
The tools I cannot find:
Text Alignment: I want to have the text aligned to the middle (it is available for UILabel, but I don't see this option in UIButton).
Button Edges: I want to use Type >> Custom so I can have control over the button color and opacity; still, I wish to have rounded edges (like the Type >> Rounded Rect has). How can I do that?
Edges Style/Design: If/Once I have these rounded edges for the button, I wish to set the width of the edges and its color (to have this nice frame). Is it possible?
If I can do it via Interface Builder, I prefer that; I don't mind setting these attributes via code as well...
Any assistance would be very much appreciated.
For that level of customizability you'll have to make a custom button and either draw it in code or use images. Things like corner radius and edge style are not customizable in interface builder.