Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How set custom fonts for iOS13 context menu actions?

I want to customize the action buttons on context menu for iOS 13+

Menus are something like this:

enter image description here

I thought I could set the custom font like UIAlertController actions like this:

let action = UIAction(title: "asdasd") { _ in}
let attributeString = NSMutableAttributedString(string: action.title)
attributeString.addAttributes([NSAttributedString.Key.font : font], range: NSMakeRange(0, action.title.count))
action.setValue(attributeString, forKey: "attributedMessage")

But its not work like that, so how is it?

like image 611
Ahmadreza Avatar asked Oct 15 '22 04:10

Ahmadreza


1 Answers

You can't force it to use a specific font and or text size. It actually supports dynamic text. So its size will depend on the user device settings. Settings > Display & Brightness > Text Size and Settings > Accessibility > Larger Text (iOS 14). So yon can't use a custom font because context menu supports dynamic text. The font used by dynamic text depends on the system therefore San Francisco has been the font used by Apple since iOS 9. For more info about Dynamic Type in iOS you can read this article.

like image 101
Leo Dabus Avatar answered Oct 31 '22 21:10

Leo Dabus