Group Group Group Group Group Group Group Group Group

How do you increase font size for the text in an Alert Message

I just recently started working on the beginning “Your First iOS and SwiftUI App” video.
I’ve been playing around with specific “Modifiers” one of which is for changing font size.
Just using a Text View I’m able to alter the font size by using .font(.largeType).
This works every time for any font size that I choose.

I’ve tried to apply this same modifier to the title in an Alert View. Swift lets me add this modifier
but it doesn’t allow the text size to change accordingly. So, what am I doing wrong or is it because the Alert View is limited in size and can’t be modified.

Thanks for your help.

Here’s my code :

import SwiftUI

struct ContentView: View {
@State private var showAlert: Bool = false
var body: some View {
VStack {
Text(“My First App!”)
Button(action: {
print(“Hit Me!”)

      self.showAlert = true
    }) {
      Text("Hit Me!")
    .alert(isPresented: $showAlert) {
      () -> Alert in
      return Alert (title:Text("Hello World!")
                    , message: Text("This is my first pop-up.")
                      , dismissButton: .default(Text("Super!")))


1 Like

I’m 99% sure you can’t change the standard alert this way.

You’d have to create a custom alert :+1:

Thanks for your reply. I’m now convinced that that’s true.

For views that can’t be altered, it seems like you should get an error message explaining why you can’t apply these modifiers. Instead, SwiftIU lets you apply modifiers to these types of "unchangeable " views as if they would work.

1 Like

Can anyone tell me is there any way to change the font size for alrt messages

I tried with visual atrributes,property classes

All the size is same .No change .The color changes

please tell me any way to increase the size of alrt messages


Today Match Prediction Get Live Ball by ball Today Cricket Live Match Score Card Auto Update,Who Will Win Today Match.

As far as I know, it is not possible.

However, you have a several choices:

If you want to create it yourself as a totally custom thing, create a new div element in your DOM (as the last child of the body, and give it the maximum z-index you can or you use), position that absolute (top:0,left:0), and write there HTML whatever you want. With some JS you can position it to center of the screen/layout. :slight_smile:

Or use jQuery UI Dialog

@elianawilson @elearner is asking this question in the context of SwiftUI.

@elearner ,
You cannot modify them via swiftUI, UIKit developers would try to subclass or extend the classes to change/modify the font sizes. However it is advised to leave it to system default as it will adapt based on the user settings.

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.