How to approach for creation of below Custom View? - ios

I have a view as below. Which have dynamic image whose height can vary and the text on right side of image and below the image. Both text should come as paragraph as we see in textbook. So what is best approach to achieve this. Is it possible to have both paragraph in implementing with one UILabel?

Related

how to draw hexagonal image in a UICollectionView

I have created a dynamic page in order to show profiles of the user. For that i have used collection view cell, what i want is that i have to represent those profiles in a numeric manner and that too inside a hexagon shaped image. Kindly can anyone give me some ideas how to do it. Am pretty much confused. Here is the screenshot of how the dynamic page should look like.
Solution is very simple. Just use UIImageView with hexagonal image.jpg just like shown in above cells, and show UILabel over UIImaeView, which shows Number in white font.

Adding UITextField inline UILabel (Fill in the blanks)

I am trying to achieve something like this for iOS in Objective C.
The fill in the blanks(UITextField) should be inline, and should be able to have its own inputType.
Also, each View is a type of cell.contentView of a UITableViewCell.
My current approach is to find the length of string and also calculate the wrapping content length to the next line. Calculate the x's and y's for UITextField and add another UILabel after the UTextField
Is there any other approach other than this?
As EmilioPelaez says, this is not exactly an answer to your question, but a suggestion:
You can use a collection view with an horizontal flow for each "sequence" (i.e. UILabel-UItextfield-etc...)
That collection view has 2 kind of cell:
One with a uilabel with the number of line set to "1"
and the correct layout to fit the cell.
Another with a uitextfield and the correct layout
Coupled with:
My current approach is to find the length of string and also calculate the wrapping content length to the next line.
You may be able to easily adjust the width of the different cells, hide a uitextfield (if needed) and display a more dynamic "sequence" (if needed)
This is not exactly an answer to your question, instead it's a suggestion for a different interaction.
I think that instead of using inline textFields, you could use a UILabel with an attributed string, and in where the textFields would be, you add a different character with a different color that you can tap (For example, this character ✚).
When tapped, you can show an overlay with a text input, and once that input is completed, you update the label with the text (still tappable, and with a different color).
I think this answer might also be relevant: Detecting taps on attributed text in a UITextView in iOS
I think your solution of separating the UILabels and calculating their required positions is a good one for versions lower than iOS9, but if you can count on iOS, UIStackView can dramatically simplify the process for you. You can read more about the process in this tutorial:
UIStackView Tutorial
Good luck!

RichText label or 'flow' layout for text in iOS (Xamarin/MonoTouch)

I am trying to repduce a similar sort of layout as in the screenshot below from the Digg app..
Notice that each list entry has a title in bold followed by the source, posted time and finally if there is enough space the start of the description line.
The question is what is the best way to achieve this in iOS? With some posts having longer titles than others I cannot simply say that the title label is 40px high and then place the Source label at 45 as the title will sometimes be longer and sometimes shorter.
Do I have to calculate the height of the label based on its contents before arranging the layout or is there some better way of doing this in iOS so that the views 'below' are automatically moved down?
Another alternative would be some sort of rich text label that I could add all the text to and have it automatically wrap round moving the later text down but I cannot find any sort of control in standard iOS / Xamarin (MonoTouch).
Any pointers would be greatly appreciated?
If you are using a storyboard the simplest way to achieve this result is to define different prototype cells. For example, you could define four different prototype cells, each one with a different layout like those shown in the example picture you provided. You can dequeue the appropriate cell based on the content you want to display so there is no need to adjust the layout in the code.
If you are doing everything in code, it's a lot more complicated since you have to build your own "layout engine" to adjust size and position of the views in your cell. You can have a look at XibFree or use MonoTouch.Dialog as suggested in the comments.

Best way to create a bar graph with UIImageView?

I have a UITableView with several sections. In each section are rows with various items. I have a custom UITableViewHeaderFooterView for each section and I would like to set the background image for each one to illustrate a particular percentage associated with each section.
I was thinking I could have a simple image with a line and two colors on either side and somehow scale/translate this image so that the line and bar color would fill up the table header from left to right in accord with the percentage value for that section. This changes so I would need to be able to re-draw it whenever the values change.
I figured that if the image did not scale to fit, but rather the left and right edges were set to bleed instead of tile, then I could just reposition the image in the view. But I'm not quite sure how to go about that, or even if that's a reasonable thing to do. Just looking for advice on a good approach for this sort of effect.
You can add image to the image view and can show the percentage of the image to the image view as per the percentage you get in that particular sections.Fill your image view with full image and display the percentage accordingly.
Instead of using an image, create a custom UIView subclass. Give it a property or two to represent the data. Then implement the drawRect: method to draw the graph.
Use this custom view in the table header/footer view instead of an image.
This has the advantage of being more flexible. If you want the graph to be fancier or different, just update the drawRect: method as needed.

iOS UILabel Formatting Tips

Does anyone have any tips or suggestions for working with labels in iOS? I am a newbie learning to develop on iOS and come from .NET world and find it extremely hard to achieve the look I need in a custom table cell I am designing.
Basically I have a custom table cell that has two labels. One for title and second one for sub title. I want my title label to hold at most two lines of text and truncate tail of longer text. For my subtitle label I want 3 lines of text. My title label will be bold and my subtitle label will have one level smaller fonts.
The only thing I am struggling with is the label heights. How to drop labels in XCode so that they accomodate two lines of text at most (and handle single lines of text gracefully) and do the same for my subtitle label.
There may be a simple solution to this but I am missing it completely. I cannot believe a simple act of dropping the most basic UI component can be so complex in iOS. I don't want to do any hacks (i.e. drop UI Views in the cell etc) if I can avoid it.
Any help will be appreciated.
Here's a couple of tutorials that may help you with custom UITableViewCells:
http://useyourloaf.com/blog/2011/2/28/speeding-up-table-view-cell-loading-with-uinib.html
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
Hope that helps
You might want to check out the default UILabels on UITableViewCell. They are textLabel and detailTextLabel respectively. Find the relevant Apple docs here.

Resources