I have taken this code from
Changing the background color of a UIAlertView?
UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Atention"
message: @"YOUR MESSAGE HERE", nil)
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[theAlert show];
UILabel *theTitle = [theAlert valueForKey:@"_titleLabel"];
[theTitle setTextColor:[UIColor redColor]];
UILabel *theBody = [theAlert valueForKey:@"_bodyTextLabel"];
[theBody setTextColor:[UIColor blueColor]];
UIImage *theImage = [UIImage imageNamed:@"Background.png"];
theImage = [theImage stretchableImageWithLeftCapWidth:16 topCapHeight:16];
CGSize theSize = [theAlert frame].size;
UIGraphicsBeginImageContext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[theAlert layer] setContents:[theImage CGImage]];
orginally posted by oxigen.
I am not very sure should I use this code开发者_JAVA技巧 in my app. Will apple have any issues regarding this hack (will they reject the app?)
The underscores as prefixes of the properties you're accessing (_titleLabel, _bodyTextLabel) clearly indicate that these are private properties and should not be tinkered with. Apple has recently started scanning all submitted binaries for access to private methods and properties, and those values by themselves within your application should be enough to get you rejected. It is never a good idea to use private APIs, rejections or no, because they are typically private for a reason and may break your application with future OS updates.
Additionally, you are violating the iPhone Human Interface Guidelines by changing the alert color:
You can specify the text, the number of buttons, and the button contents in an alert, but you can’t customize the background appearance of the alert itself.
Again, from the iPhone Human Interface Guidelines:
Because users are accustomed to the appearance and behavior of these views, it’s important to use them consistently and correctly in your application.
Only Apple can answer that question. And they won't answer it until you submit it and wait approximately 2 weeks.
If you really want it in and have 2 weeks to kill, try to submit it. But it might get rejected at an update later.
Are you using any undocumented APIs here? If you are, assume it will get rejected. If you aren't but you are doing something different, then the only answer to your question which is correct is "I don't know".
If you want to know if some programming technique will result in rejection, make a small app with limited functionality and use your questionable technique in it.
It takes 2 weeks to get an answer but at least you won't invest a ton of time upfront.
If they approve your test app, delete it from the store. If it has genuine utility, set the price to $0.99 and leave it.
This method is not foolproof, but it is low cost.
精彩评论