Is it possible to set two colors or transparency of the portion of the cell? something like this image where you can see both dark green and light green?
I am looking for both native and Titanium Appcelerator based solution.
Thanks
It may be best to add and position a CALayer (as a sublayer) onto the existing UITableViewCell's layer and set the colours of the cell's layer and your new sublayer to your requirements.
Coding properties on your UITableViewCell.m file for convenience could also be helpful.
A useful link if you are unfamiliar with CALayers http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial
Related
I just want to know that which is the best and better way to draw/display dot in UICollectionViewCell.
I want to display dots for image/video either that image/video is shared on Social media or not. In above image, dark blue dot indicates that the image/video is shared in Facebook and light blue dot for Twitter shared.
So my question is, which is better way to achieve that?
Add UIView on cell and fill color and cornerRadius.
Make 1x,2x,3x images and display in cell with UIImageView.
Using CAShapeLayer() and UIBezierPath().
or any other way?
Which is best and how related to memory and performance?
Subclass a UICollectionViewCell and add a UIView to it with layer.cornerRadius set as well as background colour. This approach could be implemented completely programmatically or with a xib.
Actually if you want to dynamically set the dot size you can add constraints separately for each size class.
CAShapeLayer is quite memory intensive in comparison. The image view approach also unnecessary increases file size.
I wonder what the best way to create a horizontal line is?
I have a few labels / text and I would like to add a horizontal line between them. More or less like a when using twitter bootstrap.
Right now I am using a UIview and setting it as 1 in height with a black background color. But I guess this isnt the best way to do it?
That is the way to do it in iOS. UIView is the class which represent something to be shown on the screen. Every UI component is direct or indirect descendant of UIView. So, you should use UIView.
UIView is backed by CALayer to render the content to screen. You could also use CALayer, CAShapeLayer or other layer classes to create a border. But, I would not recommend to use CALayer just to show a border as it is simpler to use UIView with height of 1, on the top of that, you get some nice addition such as autolayout. If you use CALayer, you will have to set frame to layer at appropriate time when the view bounds change. It could also be tricky due to some intrinsic animation within CALayer.
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.
How do you add a simple two color gradient as background to a UICollectionView. It should cover the whole background and stay fixed even when scrolling the collection view (horizontally).
All layer based solutions I tried so far had issues regarding not covering the whole screen and covering only the initially visible frame. Bonus points for being animatable and not using images ... ;)
What's the best way to do this?
An easy and fast solution is to set the background color of the UICollectionView to 'clear' and add another UIView with the gradient behind it.
I've looked into customizing the UIPickerView, but the options to customize it the way I want to do not exist.
I want to change the "selection highlight" to be a static image behind the text labels rather than a static transparent image above it like with the default UI. I also want to take off the gradient overlay on the top and bottom of the dial.
Does anyone here have any tips on creating a custom picker from scratch or possibly subclassing a UIPickerView to do what I want?
Subclassing UIPickerView won't really help you because it'll be just one big hack, since it's appearance can't be changed. You can try using UIScrollView with paging for the rolling part, and set it's background to clearColor so your selection highlight will be visible.