1

I want to show pop-up message in my project developed in Xcode (Objective-C). I am using NSAlert for popup design. As the text I want to display is more, I want customize my pop-up box size. Is there any way to do this?

enter image description here

Brian
  • 14,610
  • 7
  • 35
  • 43
MacDeveloper
  • 1,334
  • 3
  • 16
  • 49

3 Answers3

2

You can change your NSAlert size using something like this:

NSAlert *alert = [[NSAlert alloc] init];
NSRect frame = alert.window.frame;
frame.size.height = 110;
frame.size.width = 210;
[alert.window setFrame:frame display:YES];
Victor Henriquez
  • 1,399
  • 15
  • 26
2

You can use an accessory view to enlarge your NSAlert:

NSAlert *alert = [[NSAlert alloc] init];
alert.accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 500, 0)];

Credit: this SO answer

gog
  • 1,220
  • 11
  • 30
1

NSAlert does not allow you to change its window. So you will need to write your own window controller subclass like NSAlert which is a subclass of NSObject. Pl. refer the below link, 1. NSAlert resize window 2. Creating a fully customized NSAlert where the options are provided to customize the alert view.

Also you can take a look of the iOS custom alertview form the below github link https://github.com/wimagguc/ios-custom-alertview

Community
  • 1
  • 1
shri
  • 856
  • 1
  • 10
  • 26