Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-04-2010, 07:21 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 570
aryaxt is on a distinguished road
Question UIAlertView change background???

0 down vote favorite


I am trying to change the background of the uialertview. Everything works fine except the background image i am adding to the uialert view won't scale inside the alertview. So basically you see only part of my background image based on the current size. Is there any way to make it so that the image scales inside the alerview until it fits?

Code:
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:title 
                                                    message:msg
                                                   delegate:nil 
                                          cancelButtonTitle:@"OK" 
                                          otherButtonTitles: nil];
    [theAlert show];

    UIImage *theImage = [UIImage imageNamed:@"bg.jpg"];
    theImage = [theImage stretchableImageWithLeftCapWidth:16 topCapHeight:16];
    CGSize theSize = [theAlert frame].size;

    UIGraphicsBeginImageContext(theSize);
    [theImage drawInRect:CGRectMake(0, 0, theAlert.frame.size.width, theAlert.frame.size.height)];
    theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    theAlert.layer.contents = (id)[theImage CGImage];
    [theAlert release];
aryaxt is offline   Reply With Quote
Old 08-04-2010, 09:10 PM   #2 (permalink)
r_l
Registered Member
 
Join Date: Jul 2010
Posts: 19
r_l is on a distinguished road
Default

Simply setting contentsGravity for layer doesn't work for alert view. Try with UIAlertView subclass. You can find more info Joris Kluivers :: iPhone Dev Resources here, but note that changing background of alert view is against iPhone HIG (ref: iPhone Human Interface Guidelines: Alerts, Action Sheets, and Modal Views, under Designing an Alert section)
r_l is offline   Reply With Quote
Old 08-04-2010, 09:28 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Oceanside, CA
Posts: 570
aryaxt is on a distinguished road
Default

Thanks. "You can’t customize the width or the background appearance of the alert view itself, or the alignment of the text (it’s center-aligned). "

ok so i am not changing the background appearance, i only change the color. the alertview looks exactly the same.
Is the color of UIAlertView considered it's appearance? hehe a little confusing
aryaxt is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 325
10 members and 315 guests
alexP, arash5500, gordo26, mediaspree, nobstudio, Objective Zero, rayjeong, Sloshmonster, stanny, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:23 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0