How do I center an annotation title? - ios

So I have a map with annotations that represent bikes. All of them have a title, an image, and a button. The title is on the left side by default as far as I can say. Is there any way I can center the title?

You can set the textAlignment to center
yourTitle.textAlignment = .center

Related

how to set gravity in jetpack compose Text

I have a text component that height is 48dp and want to set the text center in vertical.
Like the TextView with 48dp height and gravity is center_vertical.
Or I have to put it(Text compose) in Surface component?
Yes, that is correct, you would need to put it in a box for instance, or a column, and center it that way.
Box(modifier = Modifier.fillMaxSize, contentAlignment = Alignment.Center){
Text(text = "My Text") }

Set UiTextField cursor on top Swift IOS

I have a TextField in my storyboard with a height of 100 .
When I'm clicking the TextField the cursor is placed in center :
I would like to set the cursor position in the top left corner.
I tried :
let startPosition: UITextPosition = textField.beginningOfDocument
But it seems that the position is already at the beginning and when the height is extended the cursor stay in center.
How can it be done ?
Seems like you want a multiline UITextField. In that case you might want to take a look at UITextView, which should allow for what you want (docs)

What causes horizontal padding around title of UIButton?

I programmatically created two UIButtons and constrained them to 2 points apart (horizontally). I see extra space, so I clicked the "Debug View Hierachy" button in Xcode, and here is what I see:
What is causing the extra space around the "abc" title? I looked at a few suspect properties of the button and they are all zero. (contentEdgeInsets, titleEdgeInsets)
I haven't done anything to the buttons other than:
let b = UIButton(type: .system)
b.translatesAutoresizingMaskIntoConstraints = false
b.setTitle("...", for: .normal)
The constraints look like:
b1.centerXAnchor.constraint(equalTo: outer.centerXAnchor)
b2.leftAnchor.constraint(equalTo: b1.rightAnchor, constant: 2)
b2.firstBaselineAnchor.constraint(equalTo: b1.firstBaselineAnchor, constant: 0)
UIButton has an intrinsic minimum width of 30-pts.
So, if the title text is shorter than 30-pts, the button's title label will be centered horizontally in the button's 30-pt frame.
You can explicitly set the width to less than 30, but then you'll have to take some other steps to get your button to auto-size with a longer title.

MKMarkerAnnotationView title is not showing

Why MKMarkerAnnotationView title is getting disappearing. Some times title is appearing when we rotate map. How to make MKMarkerAnnotationView title should always visible.
MKMarkerAnnotationView has a property titleVisibility that can be set to one of the values
.adaptive
.hidden
.visible
.adaptive renders the title when there is space to do so, which is the default behaviour. If you want to see it always, set it to .visible.

changing contact add buttons color in swift

Does anybody know how to give a custom text color to the circled + sign in ContactAdd button type? Before I was thinking the circled + is the actual title of the button but I was wrong.
var addButton=UIButton.buttonWithType(UIButtonType.ContactAdd) as UIButton
println("this is the current title \(addButton.currentTitle)") \\gives nil
You can use the tint color property. Something like this:
addButton.tintColor = UIColor.blueColor()

Resources