I'm trying to reproduce the design of Twitter UITableView (see image below) :
Did not manage to reproduce it :(
I tried several methods like :
UITableViewController with self.view.layer.borderWidth = 3.0f + shadows + cornerRadius
UITableViewController with Grouped style and corner Radius
UIView with UITableView as a subview and corner radius
Any clue to solve my problem please ?
In advance, thanks a lot for your help.
In my opinion, this seems to be NOT your classic grouped style UITableView.
This could be a UITableView (plain style) that spans across the whole device width, and composed by custom UITableViewCell's. The cells are narrow enough to leave room for the scroll indicators to be shown.
Each UITableViewCell renders a UIImage on the cell's background: each different, depending on position - top, middle, bottom - or content type. The image for the cell background would already contain the shadow pixels. In an experience of mine, using Quartz for shadow, is too processor intensive and slow, iphone 4). In addition, each custom cell could also have its view setOpaque:TRUE for enhanced performance (against the solid colored background).
Each tweet cell may span different lines/heights so you'd probably use [UIColor colorWithPatternImage:[UIImage imageNamed:#"tile.png"]] when setting the background of the cell.
So we end up with no real shadow / processor intensive stuff. Just graphics, color matching and positioning.
This very similar to twitter UI
https://github.com/vicpenap/PrettyKit
I have used a simple trick wherein you use a UIView "Vbg" under UITableView and set the colour of cells and Table to clearcolor. Then increase the height:
Vbg.heightConstraint.constant = number of cells * height of cell.
I had to use this for fixed height cells , so this trick came up my mind and it worked pretty well.
Related
Given that using the minimumInteritemSpacing / minimumLineSpacing settings on an iOS collection view creates a space rather than a solid border between cells, how can we style a solid border of consistent width around each cell in a collection view grid with a seperate colour applied as the background to the main collection view (so that after the border of the last cell a different background colour is visible) using these methods?
This is the best example of a solution I have seen so far but it is for objective C only rather than swift 3. The author also outlines the shortcomings of a couple of approaches I have already tried:
UICollectionView custom line separators
As an additional note the grid contains items of varying dimensions as illustrated here:
github.com/Antondomashnev/ADMozaicCollectionViewLayout
Edit - Here is an image of the effect I'm trying to achieve:
Custom CollectionView
It also highlights the problem that whil]1st the blue borders are most easily created using minimumInteritemSpacing / minimumLineSpacing the spaces created (whilst accurate and evenly spaced) just show the colour of the background view beneath the cells so you are left with one solid colour as opposed to the blue and yellow combination shown in the image.
I was able to get the result I wanted by setting a minimumLineSpacing and minimumInterimItemSpacing value of 0 to group the cells together and dynamically adding / removing borders as CALayers using krotov's answer here: UIView bottom border?
How can i achieve following in ios 7 ??? I want rounded corners around uitableview for first and last cell only.
It is basically a UItableView that have a rounded corner.
Import quartz Core framework and try to change the corner radius of the tableView itself using tableView.layer.cornerRadius = float value;
iOS 7 does not support rounded corners in grouped tables anymore.
iOS 7 is a major overhaul of the whole GUI. Many things have changed, including the appearance of the UITableViews.
You can try to create a custom cell which draws a rounded rect. You have to identifiy the first and last cell in your TableView and only draw the custom View, Background, whatever for those cells.
How to customize the appearance of the UITableView was also discussed here:
changing corner radius of uitableview grouped in iOS6
Although this link is for iOS 6 the mechanic should be the same in iOS7.
I am building an app that is presenting articles from a blog. I am using UICollectionView to present images that are parsed from the blog for each of the cells. This is my first go-round with a UICollectionView so I am wondering how you set up a background image of something like shelves that will scroll with the UICollectionView?
I have tried using:
self.collectionView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"shelves.jpg"]];
But this doesn't do anything.
What you're trying:
self.collectionView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"shelves.jpg"]];
should work. I do exactly this in viewDidLoad and it works for me. I would check that you're getting a valid image. Perhaps "shelves.jpg" needs to be added to the project?
You can just set the size of a UIImageView for your background to a size that is larger than the current UIView size then change the origin (increment) of that UIImageView based on your current visible cells for your UICollectionView. This would give you a side scrolling (parallax) effect based on which cells are currently being viewed.
There are other parallax effects people have created that you can get creative with to apply to your scenario. The idea is pretty simple.
I'm trying to create UITableView with vertical gridlines, using method described here: http://www.iphonedevx.com/?p=153 . Everything works fine, until I switch table style to grouped.
Vertical lines just don't appear on the table, though overridden drawRect: is still called.
What am I doing wrong? Is there some major difference between cells for grouped and plain UITableView? Is it possible at all to draw primitives on the cells for grouped tables?
Thanks in advance.
PS: I'm using XCode 4, iOS SDK 4.3 and running the project with iPhone 4.3 simulator.
Just looking for the same. Found this guy's blog. It looks promising. He uses a custom png with the grid to complete the effect.
OK, I've found a solution myself.
I've subclassed UILabel, which represents a single cell in a grid. Override of drawRect: draws path with rounded corners and fills it with desired color. Background color of a label is set to clear color, otherwise no rounded corners for me.
Then I've subclassed a UITableViewCell that adds labels to itself. To simulate margins it adds offsets to labels' frame.origin.x and frame.origin.y.
All this stuff contained in a plain UITableView, but with margins and rounded corners it looks like a grouped one.
How do you add counts inside of a UITableView UITableViewCell like the iOS Mail app?
In addition to DDBadgeViewCell (mentioned by #micpringle), there's also TDBadgedCell.
I tried out both and found TDBadgedCell to suit my needs more, as it puts the badges over the cell's text rather than under it, meaning the badges are visible even for cells with long texts.
The project also seems to be (currently, at least) more active than DDBadgeViewCell. (That being said, there seems to be a bug in the non-ARC version of TDBadgedCell.)
Create a custom UITableViewCell, position the labels where you want them (title, subtitle, count, whatever you need). I highly recommend Matt Gallaghers custom UITableView code - it takes a lot of the headaches out of dealing with custom rows. You'll have to follow Matt Gallaghers steps for customizing the cell.
To get the appearance of the count label as close as possible to your example (mail.app), you'll have to set the UILabel backgroundColor to gray (or whatever color you want it to be), textColor to white, and layer.cornerRadius to something equal to half the height of the label (if label is 20 high, cornerRadius should be 10). This will result in a UILabel with white text, gray background, round corners. Note - this isn't the most efficient method of doing this, but Apple hasn't put up the WWDC session video where they explain the performant method better (I missed that session).
The easiest solution would be to set an UILabel as accessoryView or using a custom UITableViewCell subclass which could be designed using IB.
I'd recommend creating a simple rounded UIView and a UILabel as a subview in it. I'd probably create a UITableViewCell subclass to manage the content.
Definitively the most easy way would be using a ready-to-use class like TDBadgedCell