【发布时间】:2017-01-06 14:24:11
【问题描述】:
我布置了一个模糊的背景,然后是一个滚动视图,其中我放置了 UILabel 等,其中一些我想充满活力,而其中一些我想显示为白色文本。
给定静态视图,这可以正常工作,因为不需要滚动功能。但是,鉴于需要,我面临将 UILabel 放在 vibrancy.contentView(并添加活力)或滚动视图(并添加可滚动性)中的选择,但不是两者兼而有之。
编辑:
这里有一个解决方法:
UIBlurEffect * blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVibrancyEffect * vibrancy = [UIVibrancyEffect effectForBlurEffect:blur];
UIVisualEffectView * vs = [[UIVisualEffectView alloc] initWithEffect:blur];
[vs setFrame:self.view.bounds];
[self.view addSubview:vs];
scroller = [UIScrollView new];
scroller.frame = CGRectMake(0, 80, w, h-80);
scroller.showsHorizontalScrollIndicator = false;
scroller.showsVerticalScrollIndicator = false;
scroller.delegate = self;
[vs addSubview:scroller];
vsv = [[UIVisualEffectView alloc] initWithEffect:vibrancy];
[scroller addSubview:vsv];
UIView * view = [UIView new]; //WITHOUT VIBRANCY
[vsv addSubview:view];
UIView * view = [UIView new]; //WITH VIBRANCY
view.frame = CGRectMake(20, yOff, w-40, 50);
[vsv.contentView addSubview:view];
vsv.frame = CGRectMake(0, 0, w, yOff); //RESIZE ALL
scroller.contentSize = CGSizeMake(w, yOff);
【问题讨论】:
标签: ios objective-c uiscrollview