UITableView create a badge on the right of every cell - iphone

I want to create a table view like this one with a badge on the right. Can someone suggest me how can I do to get this result?
thanks

I'm using greate open source project TDBadgedCell from Tim Davies for that purposes. It is very simple to use and configure.
Get it here: https://github.com/tmdvs/TDBadgedCell

AFAIK, this is not available by default. You have to customize your cell.
Create a UILabel.
Set textAlignment as UITextAlignmentCenter.
Change its cornerRadius.
Add a drop shadow using shadowColor, shadowOffset(a positive offest) ,etc.,
Set label's text.
Resize label's width to fit the text.
Set it as cell's accessoryView.

Related

TableView Row with a badge number

How can I add a badge icon to a row in a table view?
An example of this would be the mail app in iOS where the inbox row has a badge icon showing you the number of unread messages?
Thanks!
TDBadgedCell is a good solution for this requirement.
You will have to create it yourself as there are no template cells for this. Luckily its very simple, create a custom cell with a styled label for the number and update it in cellForRowAtIndexPath: based on the information in your model object.
Either create a custom tableViewCell with a UILabel as a subview in it, or add the UILabel to a cell's contentView.
I would recommend creating your own (custom) tableViewCell though.
To get the badge shape for your label, you can play with 'cornerRadius' to get a round shape, and set the backgroundColor, textColor and borderWidth, and borderColor.
Once you get the unreadCount, just assign it to your customCell's badgeLabel's text property.
Simple as that !

how to write text on selection indicator of uipickerview

how to write text on selection indicator of uipickerview
The simplest approach will be just to add UILabel with your text over the UIPickerView. You only need to find the right coordinates so text will be placed well.
If you want to display text on it try adding a UILabel as a subview to the view containing the picker. You just need to get the frame in the right spot - easy with IB, more trial and error through code. The set label to have a clear background. Just update the label value as needed.

How to design rounded boxes and separators (like the App Settings view)?

I am wondering what is the good way to design interfaces such as the one in the Settings view on an application, for instance :
What I want to do is the nice round rectangle to separate categories and horizontal line separators between categories, I can have a label, text field, slider or any other control in each line...
Do we need to use an image in the background, that seems quite dirty to me, and I cant find any control in IB that seem to do the same kind of layout.
So, how is this done?
Thanks!
Use a UITableView and set it's style to UITableViewStyleGrouped. Remember that the standard UITableViewCell's will just let you show some text and you may need to create custom UITableViewCell's to achieve more (for example, a on-off switch).
If you wan't to customise it you can add a background image. To do this, place a UIImageView behind the UITableView and make sure you set the UITableView background colour to clear:
theTableView.backgroundColor = [UIColor clearColor];
To seperate the categories make use of the "sections".
Basically, you can use grouped table.You can have sections with different/same number of rows.

UITableView editing accessory view divider color

I have a UITableView with the editingAccessoryType set to UITableViewCellAccessoryDisclosureIndicator. The result is this:
alt text http://cl.ly/8e02045ab41ae71f6f64/content
It works, but I have a custom background, and therefore a custom separator color. However, the divider between the rearrange control and the accessory is set to the same standard table view separator color. Is there any way to change this?
You want to change the color of disclosure indicator and the rearrange control, I guess, but there is no documented way to do that.
In my opinion you should use the images for this. Have the images of desired color and paste them in place where you want to add them.
Hope this helps.
Thanks,
Madhup

Creating UITableViewCell with add photo button like in Contacts app

When you add a new contact, the first row contains the add photo button and the x co-ordinate of start of the cell is set to some value which is greater than the rest of the cells. How can this photo button be added and the cell frame can be changed?
Thanks!
They use a custom cell to achieve this. This custom cell has the picture-like control on the left and mimics a table cell next to it. It's not something that comes out of the box.
You can't set the x co-ordinate of a cell either, you can set the indentation on the other hand.
Edit: come to think about it, they probably use a custom table header instead of a custom cell. You certainly will find the headerfooter sample on developer.apple.com helpful.
Link: https://developer.apple.com/library/archive/samplecode/HeaderFooter/Introduction/Intro.html
I am more inclined to believe that they use tableHeaderView property.
Sure you can achieve the effect with custom cell.
But with header its pretty simple! I have done the same in few places!