进行自定义时,屏幕上会出现图形的白色斑点UIActionSheet
。
当我将* background设置为除透明以外的任何其他颜色时,图形白点消失。
屏幕截图:
这是我的代码:
- (void) customisingActionSheet
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@""
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0,0,320, 315)];
background.backgroundColor = [UIColor clearColor];
[actionSheet addSubview:background];
self.customActionSheet = actionSheet;
UIButton *cancelButton = [UIButton buttonWithType: UIButtonTypeCustom];
cancelButton.frame = CGRectMake(15, 111, 290, 45);
[cancelButton addTarget:self action:@selector(cancelButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
cancelButton.adjustsImageWhenHighlighted = YES;
[cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
cancelButton.backgroundColor = darkGrey;
cancelButton.titleLabel.textAlignment = NSTextAlignmentCenter;
cancelButton.titleLabel.font = [UIFont fontWithName: @"HelveticaNeue-Medium" size: 17];
[self.customActionSheet addSubview: cancelButton];
UIButton *chooseFromLibrary = [UIButton buttonWithType: UIButtonTypeCustom];
chooseFromLibrary.frame = CGRectMake(15, 52, 290, 45);
[chooseFromLibrary addTarget:self action:@selector(emailResultsTapped:) forControlEvents:UIControlEventTouchUpInside];
chooseFromLibrary.adjustsImageWhenHighlighted = YES;
[chooseFromLibrary setTitle:@"Choose from Library" forState:UIControlStateNormal];
[chooseFromLibrary setTitleColor:[UIColor colorWithRed:53/255.0f green:53/255.0f blue:53/255.0f alpha:1.0f] forState:UIControlStateNormal];
chooseFromLibrary.backgroundColor = [UIColor whiteColor];
chooseFromLibrary.titleLabel.textAlignment = NSTextAlignmentCenter;
chooseFromLibrary.titleLabel.font = [UIFont fontWithName: @"Helveticaneue" size: 17];
[self.customActionSheet addSubview: chooseFromLibrary];
UIButton *takePicture = [UIButton buttonWithType: UIButtonTypeCustom];
takePicture.frame = CGRectMake(15, 0, 290, 45);
[takePicture addTarget:self action:@selector(emailResultsTapped:) forControlEvents:UIControlEventTouchUpInside];
takePicture.adjustsImageWhenHighlighted = YES;
[takePicture setTitle:@"Take picture" forState:UIControlStateNormal];
[takePicture setTitleColor:[UIColor colorWithRed:53/255.0f green:53/255.0f blue:53/255.0f alpha:1.0f] forState:UIControlStateNormal];
takePicture.backgroundColor = [UIColor whiteColor];
takePicture.titleLabel.textAlignment = NSTextAlignmentCenter;
takePicture.titleLabel.font = [UIFont fontWithName: @"Helveticaneue" size: 17];
[self.customActionSheet addSubview: takePicture];
[actionSheet showInView:self.view];
[self.customActionSheet setBounds:CGRectMake(0,0,320, 315)];
}
有人有解决方案吗?非常感谢。
UIActionSheet
不能被设计为子类化,也不应在其层次结构中添加视图。如果您需要为表单提供比UIActionSheet
API提供的更多的自定义设置,则可以创建自己的表单并使用进行模态呈现presentViewController:animated:completion:
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句