NSAttributedString boundingRect returns wrong height
问题 I calculate the height of an NSAttributedString like this. let maxSize = NSSize(width: w, height: CGFloat.greatestFiniteMagnitude) let rect = boundingRect(with: maxSize, options: [.usesFontLeading, .usesLineFragmentOrigin]) let height = rect.integral.size.height I tried about every "hack" that was mentioned on SO, yet the string height gets more inaccurate the smaller the width gets (the calculated height is larger than the actual height). According to other posts the following things cause