Custom UITableViewCell - ios

Does anybody have the slightest idea on how I can achieve this type of effect on my table view cells?
or do you guys know a blog, Git, Repo that has nice TableViewCell make ups? thanks

In your storyboard, make everything transparent and set those images as your background.
Then you can use '
UIVisualEffectView | UIVisualEffectView with Blur class
' to set those blurs on your custom cells, make sure that your cell's background color is also in transparent mode.
or use
CAGradientLayer Class
to set them up.

If table's cell are static then you can create static custom cell in storyboard, Use Pin option in storyboard set left and right constraint for auto layout. Use background image and UILabel for creating for creating cell.

check the below link, it will help you.
use your own background image and font colur.
Customize UITableView and UITableViewCell
http://www.appcoda.com/ios-programming-customize-uitableview-storyboard/

Related

How can I get a listview like the following Apple Music playlist overview?

I am searching for a Listview in Swift that looks like the following:
Wanted ListView:-
I want a ListVIew that has a picture in the background and a text over the picture. And when I click at that picture, I want to go to the next site.
And how I get these Header?
Header Example:-
Can someone help me?
Implement the UITableView with customTableCell.
On your customTableCell class draw the custom design as shown in your requirement image. (Set a background image. Set a left aligned label.)
Implement the didSelectRowAtIndexPath delegate method to goto the next site.
Set the accessoryType of cell to UITableViewCellAccessoryType.DisclosureIndicator
Custom header:- Set the translucent navigation bar. Set the custom image in your headerview.
You need to implement UITableView to achieve your requirements mentioned in question. You can use custom cell and can add UIImageview and UILabel on it to show image and title. Second thing you can implement tableHeaderView which can fullfill your need of header. Tableview is memory efficient with great performance. So, in your case UITableView is the right choice.

How to make a UITableView look like this?

I'm curious of how Youtube `s UITableViewCells are done, here is a screenshot:
Like you can see the cells are like squared and centred, how can I do that?
While you actually can use UICollectionView instead of a UITableView, this layout (YouTube App) can actually be achieved with UITableView as well.
You will need to create a custom UITableViewCell, that has few images and labels. When you create a custom UITableViewCell, you add items to the contentView property. You can then change the constraints or frame of the contentView property to achieve the effect.
Of course, there are more ways to achieve this layout, but I would follow this one:
Create a custom subclass of UITableViewCell.
Give UITableViewCell a clear background.
Give white background to the contentView UIView property of the created subclass.
Add constraints for margin between cells to contentView in UITableViewCell.
Design the layout of the cell in contentView.
It is basically not hard to create a design like this.
Use a UICollectionView instead of a UITableView
Cells are automatically centered, just create a square size.

iOS: UIView backgroundColor in table view

So this problem is pretty weird and a little difficult to describe. Essentially I have a UITableView where each cell has an image, and a UIView covering part of the image. The UIView has it's background colour set to about 30% transparent white, giving it the appearance of washing out the image beneath. There's also some labels and such on it. All these views are added to a single parent container view, which is finally added to the cell's contentView. This all works fine - until I try to select the cell. For some reason, whenever the cell is highlighted, the backgroundColor property on each and every one of those views is set to clear, until the cell is unhighlighted (at which point the old colour returns).
Can anyone explain why this happens, and more important if there's a way to fix it? At most I could create a single pixel image of white, turn the UIView into a UIImageView, and set it's image to that pixel - but that's inelegant at best. Any suggestions?
When you select the cell, the implementation of setSelected:animated: is called and set the background color of all the views included in this cell to transparent.
Simply, you can just disable the selection of the cell by setting its selectionStyle to None:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Or, if you want to use the result of selection, you can override the setSelected:animated: method and reset the background color of your UIView

Change UITableViewCell background color in Interface builder

I'm trying to avoid adding any code to my iOS project that has to do with visual set up since that's what Interface Builder is supposed to streamline for you.
So I'm trying to set up the prototype cell in IB and then just call:
TableCell *cell = [self.tableView dequeueReusableCellWithIdentifier:#"TableCell"];
The problem is if I change the background color for the cell in IB it remains white when I run my application. I can preset the color of the label fine but not the background color attribute in the Table Cell.
As an additional note, I can see that the UIView that is the backgroundView inside the cell is null after breakpointing and inspecting the variable after it's been initialized.
UPDATE
I'm getting the impression that the option for background color in IB is essentially useless? I'd rather not believe that.
You cannot do that unfortunately.
Change the background colour of the cell in tableView:willDisplayCell:forRowAtIndexPath:
From the documentation of UITableViewCell:
Note: If you want to change the background color of a cell (by setting the background color of a cell via the backgroundColor property declared by UIView) you must do it in the tableView:willDisplayCell:forRowAtIndexPath: method of the delegate and not in tableView:cellForRowAtIndexPath: of the data source. Changes to the background colors of cells in a group-style table view has an effect in iOS 3.0 that is different than previous versions of the operating system. It now affects the area inside the rounded rectangle instead of the area outside of it.
In interface builder, add a view as a subview of the cell, that will be your background view. You can then add all labels or anything else as subviews to that view. Change that views background color as you want.
I think this is probably a bug in IB. You can add views to that bar at the bottom of the controller, and then connect those views to the backgroundView and selectedBackgroundView properties of the cell. However, the backgroundView's color doesn't work, while the selectedBackgroundView's color does work correctly. If you add a background view in code to a custom table view cell and give it a backgroundColor, that does work.

UITableViewCell customization, where to attach subviews?

when subclassing UITableViewCell to define a complete custom cell what style to set? UITableViewCellStyleDefault? Actually I don't need neither the label or the imageView, would they be allocated the same?
So when attaching my custom views to the UITableViewCell subclass, is it better to add to self, or to self.contentView?
And is it ok to do some quartz drawing in drawRect in the UITableViewCell subclass (Like background) ?
Thanks
when subclassing UITableViewCell to define a complete custom cell what style to set? UITableViewCellStyleDefault? Actually I don't need neither the label or the imageView, would they be allocated the same?
Since you are not using any of the pre-defined UILabel or UIImageView subviews of UITableViewCell, it doesn't really matter. I just use UITableViewCellStyleDefault. I do not know for sure if the UILabels or the UIImageView are allocated or not. However, since there is no way to explicitly tell the UITableViewCell not to create those subviews, I wouldn't worry about it. Even if they are created, you aren't using them so drawing the cell will not be any slower, and since cells are reused as you scroll through the table, allocating just a few extra objects once is not going to affect your overall table view performance.
So when attaching my custom views to the UITableViewCell subclass, is it better to add to self, or to self.contentView?
All of the content should be put in the UITableViewCell contentView. This will ensure that the contents behave properly when the UITableView has an index on the right or if the UITableView (or UITableViewCell) go into editing mode.
And is it ok to do some quartz drawing in drawRect in the UITableViewCell subclass (Like background) ?
The recommended approach is for the background to be placed in the UITableViewCell backgroundView property. So I would not recommend doing any drawing in the UITableViewCell subclass itself. Just use the contentView, backgroundView, and selectedBackgroundView properties. You can create a simple UIView subclass and just set that as the backgroundView of the UITableViewCell, if you like.
If you want to create a custom UITableViewCell, my experience is that it's much easier to use IB instead of code--even if you prefer using code normally. I would definitely recommend taking a look at these two links:
Creating a custom UITableViewCell in iOS 4
Custom UITableViewCell
This sounds like exactly what you're looking for -- you don't have to use the label or the image in this case, and you can make outlets to any custom UIViews that you need.
what style to set? UITableViewCellStyleDefault?
it depends on your aims. The most used style is UITableViewCellStyleDefault.
See Using Cell Objects in Predefined Styles
is it better to add to self, or to self.contentView?
developer.apple.com recommends to add subview to self.contentView (they specially call it as contentView).
is it ok to do some quartz drawing
It also depends on your aims. If you use only images or colors for background, then customize your cell view in IB, I don't see the reasons to use qurtz framework.

Resources