需要在actionsheet修改imageView的边界属性:
<!-- language: lang-c -->
#pragma UIActionSheetDelegate Methods
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
/*[[[actionSheet valueForKey:@"_buttons"] objectAtIndex:0] imageView].frame = CGRectMake(0, 0, 25.0f, 25.0f);*/
[[[actionSheet valueForKey:@"_buttons"] objectAtIndex:0] imageView].bounds = CGRectMake(0, 0, 25.0f, 25.0f);
/*UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 25.0f, 25.0f)];
imgView.image = [UIImage imageNamed:@"symbol-pin.png"];
[[actionSheet superview] addSubview:imgView];*/
}
然后在编码之后什么也出现:
[[[actionSheet valueForKey:@"_buttons"] objectAtIndex:0] imageView].bounds = CGRectMake(0, 0, 25.0f, 25.0f);
创建actionsheet的代码:
<!-- language: lang-c -->
- (IBAction)showModeOptions:(id)sender {
if (!modeOptions) {
modeOptions = [[UIActionSheet alloc]initWithTitle:@"" delegate:self cancelButtonTitle:@"Abbrechen" destructiveButtonTitle:nil otherButtonTitles:@"Pin",@"Linie", @"Polygon", nil];
[[[modeOptions valueForKey:@"_buttons"] objectAtIndex:0] setImage:[UIImage imageNamed:@"symbol-pin.png"] forState:UIControlStateNormal];
[[[modeOptions valueForKey:@"_buttons"] objectAtIndex:1] setImage:[UIImage imageNamed:@"symbol-line.png"] forState:UIControlStateNormal];
[[[modeOptions valueForKey:@"_buttons"] objectAtIndex:2] setImage:[UIImage imageNamed:@"symbol-polygon.png"] forState:UIControlStateNormal];
modeOptions.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
}
[modeOptions showFromTabBar:self.tabBarController.tabBar];
}
图片是88*88px的,我需要图片像imageView是25*25px的边框。不知道应该怎么实现?