Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7726097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:07:43+00:00 2026-06-01T05:07:43+00:00

I have an application where I am showing an alert message using UIAlertView. By

  • 0

I have an application where I am showing an alert message using UIAlertView. By default the color of the dialog box is blue. Can anyone tell me, how to change the color of that? Can it be changed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:07:45+00:00Added an answer on June 1, 2026 at 5:07 am

    Use Like This

       [CustomAlert setBackgroundColor:[UIColor blueColor] 
        withStrokeColor:[UIColor greenColor]];
    

    .h and .m File’s Content

    CustomAlert.h

    #import <UIKit/UIKit.h>
    
    @interface CustomAlert : UIAlertView
    {
    
    }
    
    + (void) setBackgroundColor:(UIColor *) background 
        withStrokeColor:(UIColor *) stroke;
    
    @end
    

    CustomAlert.m

    #import "CustomAlert.h"
    
    @interface CustomAlert (Private)
    
    - (void) drawRoundedRect:(CGRect) rect inContext:(CGContextRef) 
        context withRadius:(CGFloat) radius;
    
    @end
    
    
    
    static UIColor *fillColor = nil;
    static UIColor *borderColor = nil;
    
    @implementation CustomAlert
    
    + (void) setBackgroundColor:(UIColor *) background 
        withStrokeColor:(UIColor *) stroke
    {
        if(fillColor != nil)
        {
            [fillColor release];
            [borderColor release];
        }
    
        fillColor = [background retain];
        borderColor = [stroke retain];
    }
    
    - (id)initWithFrame:(CGRect)frame
    {
        if((self = [super initWithFrame:frame]))
        {
            if(fillColor == nil)
            {
                fillColor = [[UIColor blackColor] retain];
                borderColor = [[UIColor colorWithHue:0.625 
                    saturation:0.0 brightness:0.8 alpha:0.8] 
                        retain];
            }
        }
    
        return self;
    }
    
    - (void)layoutSubviews
    {
        for (UIView *sub in [self subviews])
        {
            if([sub class] == [UIImageView class] && sub.tag == 0)
            {
                // The alert background UIImageView tag is 0, 
                // if you are adding your own UIImageView's 
                // make sure your tags != 0 or this fix 
                // will remove your UIImageView's as well!
                [sub removeFromSuperview];
                break;
            }
        }
    }
    
    - (void)drawRect:(CGRect)rect
    {   
        CGContextRef context = UIGraphicsGetCurrentContext();
    
        CGContextClearRect(context, rect);
        CGContextSetAllowsAntialiasing(context, true);
        CGContextSetLineWidth(context, 0.0);
        CGContextSetAlpha(context, 0.8); 
        CGContextSetLineWidth(context, 2.0);
        CGContextSetStrokeColorWithColor(context, [borderColor CGColor]);
        CGContextSetFillColorWithColor(context, [fillColor CGColor]);
    
        // Draw background
        CGFloat backOffset = 2;
        CGRect backRect = CGRectMake(rect.origin.x + backOffset, 
            rect.origin.y + backOffset, 
            rect.size.width - backOffset*2, 
            rect.size.height - backOffset*2);
    
        [self drawRoundedRect:backRect inContext:context withRadius:8];
        CGContextDrawPath(context, kCGPathFillStroke);
    
        // Clip Context
        CGRect clipRect = CGRectMake(backRect.origin.x + backOffset-1, 
            backRect.origin.y + backOffset-1, 
            backRect.size.width - (backOffset-1)*2, 
            backRect.size.height - (backOffset-1)*2);
    
        [self drawRoundedRect:clipRect inContext:context withRadius:8];
        CGContextClip (context);
    
        //Draw highlight
        CGGradientRef glossGradient;
        CGColorSpaceRef rgbColorspace;
        size_t num_locations = 2;
        CGFloat locations[2] = { 0.0, 1.0 };
        CGFloat components[8] = { 1.0, 1.0, 1.0, 0.35, 1.0, 1.0, 1.0, 0.06 };
        rgbColorspace = CGColorSpaceCreateDeviceRGB();
        glossGradient = CGGradientCreateWithColorComponents(rgbColorspace, 
            components, locations, num_locations);
    
        CGRect ovalRect = CGRectMake(-130, -115, (rect.size.width*2), 
            rect.size.width/2);
    
        CGPoint start = CGPointMake(rect.origin.x, rect.origin.y);
        CGPoint end = CGPointMake(rect.origin.x, rect.size.height/5);
    
        CGContextSetAlpha(context, 1.0); 
        CGContextAddEllipseInRect(context, ovalRect);
        CGContextClip (context);
    
        CGContextDrawLinearGradient(context, glossGradient, start, end, 0);
    
        CGGradientRelease(glossGradient);
        CGColorSpaceRelease(rgbColorspace); 
    }
    
    - (void) drawRoundedRect:(CGRect) rrect inContext:(CGContextRef) context 
            withRadius:(CGFloat) radius
    {
        CGContextBeginPath (context);
    
        CGFloat minx = CGRectGetMinX(rrect), midx = CGRectGetMidX(rrect), 
            maxx = CGRectGetMaxX(rrect);
    
        CGFloat miny = CGRectGetMinY(rrect), midy = CGRectGetMidY(rrect), 
            maxy = CGRectGetMaxY(rrect);
    
        CGContextMoveToPoint(context, minx, midy);
        CGContextAddArcToPoint(context, minx, miny, midx, miny, radius);
        CGContextAddArcToPoint(context, maxx, miny, maxx, midy, radius);
        CGContextAddArcToPoint(context, maxx, maxy, midx, maxy, radius);
        CGContextAddArcToPoint(context, minx, maxy, minx, midy, radius);
        CGContextClosePath(context);
    }
    
    - (void)dealloc
    {
        [super dealloc];
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Openlayers to my application. i have succeeded in showing marker when
I have an Android application that showing maps using OSMDroid. I want to get
I have to include one report in my application showing offline/online activity of few
I have a rails application which is still showing the cachebusting numeric string at
I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
I have a Silverlight navigation application, that for some reason when showing a data
I have a TextBox in my application, that it is used for showing state
Thanks in advance.. I have a windows phone application. In that I am showing
i have created a single page application of showing phonebook data in a list.
I have Webview application that uses progress bar dialog. It works fine but the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.