ary*_*axt 2 iphone background-image uialertview
我想改变uialertview的背景.一切正常,除了我添加到uialert视图的背景图像不会在alertview内缩放.因此,基本上您只能看到基于当前大小的背景图像的一部分.是否有任何方法可以使图像在alerview内缩放直到它适合?
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];
Run Code Online (Sandbox Code Playgroud)