简体   繁体   中英

UITextView Font Size

I have a blank/empty UITextView that will output a result based on user-inputs. Everything works great with one small detail that's been bugging me - the font size when it delivers the output is too small for my liking! I tried changing it in the "Attributes Inspector" of storyboard but that only affects it if I decide to have text in the box prior to an output.

My code thus far is

class FreePointViewController: UIViewController {

@IBOutlet weak var fpCoilSizeInput: UITextField!
@IBOutlet weak var fpCoilThicknessInput: UITextField!
@IBOutlet weak var fpLengthInput: UITextField!
@IBOutlet weak var fpPullForceInput: UITextField!
@IBOutlet weak var freePointResult: UITextView!

    @IBAction func freePointButton(sender: AnyObject) {
    var freePointConst:Double = 20684

    calcFreePoint.freePointCoilSize = Double((fpCoilSizeInput.text as NSString).doubleValue)
    calcFreePoint.freePointCoilThickness = Double((fpCoilThicknessInput.text as NSString).doubleValue)
    calcFreePoint.freePointStretchPipe = Double((fpLengthInput.text as NSString).doubleValue)
    calcFreePoint.freePointPullForce = Double((fpPullForceInput.text as NSString).doubleValue)

    var freePointArea:Double = M_PI * (calcFreePoint.freePointCoilSize - calcFreePoint.freePointCoilThickness) * calcFreePoint.freePointCoilThickness

    var freePoint = (freePointConst * calcFreePoint.freePointStretchPipe * freePointArea) / calcFreePoint.freePointPullForce

    var freePointFormat = "0.2"

    freePointResult.text = "The pipe is stuck at \(freePoint.format(freePointFormat)) meters"


}

I've tried adding code like [textView setFont:[UIFont boldSystemFontOfSize:15]]; just above my freePointResult.text = ... line but to no avail.

I found the answer to my own question...Check if "Selectable" is checked in the xib/Storyboard attribute inspector. If it's not selectable, the size wont be changed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM