UIActionSheet 箭头方向

1.调整ipad上UIActionSheet的arrow方向
ipad上面UIActionSheet可以有箭头,但其方向不能像popover那样调整,上面查资料有如下解决方法:
参考:http://stackoverflow.com/questions/3763324/uiactionsheet-change-arrow-position

重要的就是这两句:
Apple doesn't provide any access to internal structure for UIActionSheet's internal implementation of showFromRect, but as for arrow direction, there is actually a very hack-y way to work around this and sort of being able to change arrow direction to a desired direction.
Trick is to mess around the rect parameter in - (void)showFromRect:(CGRect)rect inView (UIView *)view animated:(BOOL)animated. Apple doesn't document this rect parameter very well, butif your original rect will give you a down arrow direction, feed in a rect with a large height and negative number origin.y will kind of push the action sheet popover all the way up thus showing a upward arrow direction. This is a extreme hack but it works consistently across firmware. 

2.应用
工作中遇到编辑头像,图片来源:camera,album两种,在Iphone上面没有问题,但在Ipad上由于上面区别就有问题了
先弹UIActionSheet,但弹出来的总是箭头向下的,我想弹个箭头向上,以便切换成Popover时在同一位置

初始代码:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"camera" otherButtonTitles:nil];
    [sheet addButtonWithTitle:@"album"];
    // avaterBtn bounds:(0,0,80,80)
    [sheet showFromRect:CGRectMake(0, 0, 80, 80) inView:avaterBtn animated:YES];
    [sheet release];


改为:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"camera" otherButtonTitles:nil];
    [sheet addButtonWithTitle:@"album"];
    [sheet showFromRect:CGRectMake(0, -200, 80, 280) inView:avaterBtn animated:YES];
    [sheet release];


从事Ios开发快一年了,以后遇到问题时不能网上搜搜解决就行,一定要深入了解其原理


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值