change title font of map callouts swift - swift

I would like to know if there is any way to change title font without creating a custom view? Something like this:
annotation.title.font = UIFont.systemFontOfSize(12.0)
I searched around, everyone says that I have to create a custom view like this tutorial, but it is so complicated and it's in objective-c.
Hope somebody have a simple way to change the font.
Thank you.

Related

What is the best way to decorate fragments of text in SwiftUI?

I need to insert custom views into Text in SwiftUI. In other words to decorate some fragments of text, like formula field in Numbers app.
I still novice in swiftUI and Xcode, so just can't figure out how to begin and google it. 🤷🏻‍♂️
I would be grateful for any help in pointing out areas for further deepening. I suppose, it's about UIKit…
UPDATE
What kind of UI element I have to use to achieve result like on picture: textfield, which may contain another intractable UI elements?
I want some words become buttons, other have image on background.
I won't give you a full answer here as it seems that you're the kind of developer who'd like to figure this out for yourself. (Please, correct me if I am mistaken in assuming this.)
The gist is that the SwiftUI way of doing it is probably still not nearly as simple to do as the UIKit way.
In UIKit, you're likely looking at creating a wrapper view or subclass of a UITextView which will manage its subviews, handle touch and text input events, and update the cursor of the UITextView.
LinkedIn's Hakawai sounds like something you could consider using to power this...
You can then expose this to SwiftUI via the UIViewRepresentable wrapper type.

Best approach to displaying text

Xcode 8.3.2
As as newbie, I'm trying to get acquainted with segues, constraints, text fields and Image Views...mainly the design elements. I'm trying to put together a cheesy recipe book of favorite recipes. I wanted to know what's the best approach to display rich text with bold text and bullet points? Labels seem to be my only option but I was wondering if there were other options? Any advice would be appreciated.
ViewController in Storyboard
As much for my approach, during my career I learned that textViews (aka C# RichTextBoxes) can be pretty tricky..
You can go with classical UILabel approach with lines in Interface Builder set to 0 and atrributedText, which contains bullet points:
This is a nice tutorial, but a bit old and would probably do it another way, but I guess for the purposes is fine...
https://wingoodharry.wordpress.com/2016/04/10/bullet-point-list-ios-swift/
I would like to state here, that TextViews are the last option everywhere with text...
Wish happy coding! :)
UILabels are best way to display text, you can use attributedText in UILabels which will enhance your UI. Multiline text is a add on.
Else try using AsyncDisplayKit.

Add borderless search buttons in UINavigationbar

Good morning, good evening !
I feel like my question is a dumb easy to solve question, but it looks like Google can't help me.
I want to add on my UINavigationBar a search button, but I want it borderless !
When I set it through Xcode I have this awful kind of button :
And I want this kind of button (from the Dropbox app) :
That would be nice if someone is able to explain me the trick to achieve this !
Thank you.
I think you have a bar button item. I have played around with it. And the Bar Buttom Item has to have a Tint of Clear Color. The actual Button a Type of Custom. Then it comes out more the way you want it (I think).
In my IB it looks like this:
It is the following
With properties like this:
And like this:
Hope it helps.
If you use Interface Builder set the button type to custom and use your image as background for the button.

How to keep 2 different fonts within the same UITextField or UITextView?

I want to set 2 different fonts within the same UITextField and UITextView . How to do it?
Its a bit of work - you'll need to use Core Text and NSAttributedString to do this.
There are plenty of tutorials and examples, although I'd suggest using someone else's already-made UILabel subclass such as:
OHAttributedLabel
or
TTAttributedLabel
As these usually have some convenience methods to make handling a lot easier.
I would do it with 2 custom textfields overlaying, both backgroundcolor:clearColor, maybe stuffed on an image that represents the background.
I don't think it is possible to handle 2 different fonts within the same UITextField or UITextView. If you want to have different font style you can either set different font style within a UIWebView or use the coreText API.
Here are some links that might help:
iPhone Development - Setting UIWebView font
the official doc on core text: https://developer.apple.com/library/mac/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html
I know you already picked a valid answer but... don't do it that way... it's not worth it. Use a webview instead and draw everything with html.
In interface builder change Text View's Text field to Attributed. In that small editor that appears you can change the font/format/color of the selected text, like in any advanced text editor.

UITextView looks different at runtime than in InterfaceBuilder

Been coding for > 20 years, but there's nothing more humbling than learning a new platform :)
Hopefully I'm not missing something silly, but I can't find a similar issue here or elsewhere on the web.
I have a UI that looks correct in Interface Builder,
but at runtime, the text in the UITextView doesn't seem to wrap, and it doesn't seem to use the font that I've chosen in IB.
I even outputted the font in viewDidLoad at runtime, and it says it's using the correct font, but visually it isn't. All fields (regardless of font selected in IB) seem to display using the default font.
Hoping someone can point out what is likely a newbie mistake, or what else I could do to diagnose.
Thanks in advance