tableview cell how do we resize cell in swift along with image and label
Give constrain to your lable hight greater equal and put line to 0.
var pickheight: CGFloat = 0.0
Write this line in
override func viewDidLoad() {
super.viewDidLoad()
tableTrip.rowHeight = UITableViewAutomaticDimension
}
Method for increase tableview cell .
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
pickheight = self.findHeightForText("Pass your text here like array value as String ", havingWidth: self.view.frame.size.width - 116, andFont: UIFont.systemFontOfSize(14.0)).height
return "YOUR_DEFALUT_CELL_SIZE" + pickheight
}
Method for find text hight for cell..
func findHeightForText(text: String, havingWidth widthValue: CGFloat, andFont font: UIFont) -> CGSize {
var size = CGSizeZero
if text.isEmpty == false {
let frame = text.boundingRectWithSize(CGSizeMake(widthValue, CGFloat.max), options: .UsesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
size = CGSizeMake(frame.size.width, ceil(frame.size.height))
}
return size
}
How to resize a cell.imageView in a TableView and apply tintColor in Swift
You can do it by another way :
1) Create custom cell with your own UIImageView
size and 2 separate labels
2) Add UIImageView
as Subview
of Cell
var cellImg : UIImageView = UIImageView(frame: CGRectMake(5, 5, 50, 50))
cellImg.image = UIImage(named: "yourimage.png")
cell.addSubview(cellImg)
Resize UITableViewCell to fit label or image and rounded corners
Here is one possible solution - may not be the best, may not do exactly what you need, but might get you on your way...
Instead of trying to manipulate the layers / masks from within your custom UITableViewCell class, use a UIView subclass as the image holder. The code of that class can handle the rounded corners and layer/mask size updating.
See example here: https://github.com/DonMag/dhImage
resize image in table view cell
You can change the frame of the imageView like this:
CGRect frame = imageView.frame;
frame.size.height = 30.0;
/* other frame changes ... */
imageView.frame = frame;
You should also look at the UIImageView contentMode property (see this post). It gives you control over how the image is drawn, and is actually a UIView property (so UIImageView inherits it). It gives you the following options:
Specifies how a view adjusts its content when its size changes.
typedef enum {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit,
UIViewContentModeScaleAspectFill,
UIViewContentModeRedraw,
UIViewContentModeCenter,
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
} UIViewContentMode;
Dynamic height table cell in IOS with multiple labels
Well, apparently the problem was the 'distribution' property of the StackView... Changing it to 'Equal Spacing' instead 'Fill proportionally' fixed it... Thanks!
Related Topics
How to Tap on a Specific Point Using Xcode Uitests
How to Get Word Wrap Information with the New iOS 7 APIs
How to Convert Date Like \/Date(1440156888750-0700)\/ to Something That Swift Can Handle
Missing Marketing Icon Xcode Bug
Uislider That Snaps to a Fixed Number of Steps (Like Text Size in the iOS 7 Settings App)
Xcode 5.1: Libcordova.A Architecture Problems
How to Use Networkreachabilitymanager in Alamofire
iOS Push Notification Banner Shown Twice for a Single Push
Apple MACh-O Linker Warning "Directory Not Found for Option..."
Fbsdkloginmanager Loginwithpublishpermissions Always Returns Iscancelled=Yes
Sbstatusbarcontroller Instance
Xcode 6 Gm - Cllocationmanager
What Is Build Object File Extension in iOS
Are Headphones Plugged In? iOS7
Keeping the Contentoffset in a Uicollectionview While Rotating Interface Orientation