1

I've noticed this question has been 'sortof' asked here. Though it seems like it is asking to change the body instead of the title. Other then that one post, which looks like a ghost town of activity, as well as some objective-c sided question and answers it appears that this might not be even possible to do.

Question: Is it possible to increase the size of the text in the title of the alert screen, and if yes, how is it done?

Here is my @IBAction

@IBAction func sortOrderTapped(sender: AnyObject) {
    let sheet = UIAlertController(title: "Sort By:", message: nil, preferredStyle: .ActionSheet)
    sheet.view.tintColor = Brower.alertBlue
    let action = { (title: String, callback: () -> Void) in
        sheet.addAction(UIAlertAction(title: title, style: .Default, handler: { action in
            self.sortOrderButton.setTitle("  " + action.title, forState: nil)
            callback()
        }))
    }
    action("Start Order", {
        self.sortByStartOrder()
    })
    action("Overall", {
        self.sortByOverall()
    })
    action("Age Class", {
        self.sortByAgeClass()
    })
    action("Bib Number", {
        self.sortByBibNumber()
    })
    action("Run Number", {
        self.sortByRunNumber()
    })

    sheet.addAction(UIAlertAction.cancelAction())
    sheet.popoverPresentationController?.sourceView = self.view
    sheet.popoverPresentationController?.sourceRect = CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height)
    sheet.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.allZeros
    presentViewController(sheet, animated: true, completion: nil)
}

P.S. This action works perfectly, no bugs or issues, all I want to do is increase the size of title: "Sort By:".

-Off topic comment- I really hate how when searching for this answer whenever I would google the question with swift in the text it would include top level finds that the only place where it had swift on the page was in the similar questions tab... How frustrating...

Community
  • 1
  • 1
TaylorAllred
  • 1,191
  • 2
  • 9
  • 20
  • Looks like NO. You need to write your own custom implementation to achieve this. – gagarwal Mar 05 '15 at 22:57
  • I'm fairly new to swift and ios in general, so this may be too much for a noob like me, but how would I write my own custom implementation to do it? Is there possibly some documentation to look at? – TaylorAllred Mar 05 '15 at 22:59
  • It seems possible, according to http://stackoverflow.com/a/31662700/3458802 in http://stackoverflow.com/questions/31662591/swift-how-to-change-uialertcontrollers-title-color – duthen Jan 07 '16 at 16:59

1 Answers1

0

Your code would look like this.

let title = "Sort By:"
let myMutableString = NSMutableAttributedString(string: title, attributes: [NSFontAttributeName:UIFont(name: ".SFUIText-Light", size: 50.0)!])

sheet!.setValue(myMutableString, forKey: "attributedTitle")

See more options Use multiple font colors in a single label - Swift

Community
  • 1
  • 1
Carlos Chaguendo
  • 2,895
  • 19
  • 24