我的代码…
接口…
typedef voID(^ActionBlock)();@interface MyVIEwheaderVIEw : UItableVIEwheaderfooterVIEw@property (nonatomic,strong) UIImageVIEw *flagImageVIEw;@property (nonatomic,strong) UILabel *leaguenameLabel;@property (nonatomic,copy) ActionBlock tapAction;@end
实现…
#import "MyVIEwheaderVIEw.h"@interface MyVIEwheaderVIEw ()@end@implementation MyVIEwheaderVIEw- (ID)initWithReuseIDentifIEr:(Nsstring *)reuseIDentifIEr{ self = [super initWithReuseIDentifIEr:reuseIDentifIEr]; if (self) { // Add customisation here... // I have trIEd everything here... self.tintcolor = [UIcolor colorWithWhite:0.961 Alpha:1.0]; self.Alpha = 0.5; // self.contentVIEw.backgroundcolor = [UIcolor colorWithWhite:0.5 Alpha:0.5]; // self.backgroundcolor = [UIcolor colorWithWhite:0.5 Alpha:0.5]; // can't remember what else. // none of it makes it transparent. It sets the colour against // a white background. i.e. 50% transparent but with a white opaque background. // so I can't see the content of the table scrolling behind it. self.flagImageVIEw = [[UIImageVIEw alloc] init]; self.flagImageVIEw.image = [UIImage imagenamed:@"placeholder_flag"]; [self.flagImageVIEw setTranslatesautoresizingMaskIntoConstraints:NO]; [self.contentVIEw addSubvIEw:self.flagImageVIEw]; self.leaguenameLabel = [[UILabel alloc] init]; [self.leaguenameLabel setTranslatesautoresizingMaskIntoConstraints:NO]; [self.contentVIEw addSubvIEw:self.leaguenameLabel]; UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(vIEwTapped)]; tapGestureRecognizer.numberOfTapsrequired = 1; tapGestureRecognizer.numberOftouchesrequired = 1; [self.contentVIEw addGestureRecognizer:tapGestureRecognizer]; [self setupConstraints]; } return self;}- (voID)setupConstraints{ // adding constraints...}- (voID)vIEwTapped{ self.tapAction();}@end
在我的UItableVIEwDelegate我正在加载头像…
- (UIVIEw *)tableVIEw:(UItableVIEw *)tableVIEw vIEwForheaderInSection:(NSInteger)section{ MyVIEwheaderVIEw *headerVIEw = [tableVIEw dequeueReusableheaderfooterVIEwWithIDentifIEr:@"headerVIEw"]; League *league = self.leagues[(NSUInteger) section]; headerVIEw.leaguenameLabel.text = league.name; headerVIEw.tapAction = ^(){ [self leagueTapped:league]; }; return headerVIEw;}
这是正常工作,标题正确显示.只是没有透明度.
我想要一个标题视图,如标准视图,您可以在其中查看在其后面滚动的表视图内容.
请你让我知道如何做到这一点.
解决方法 请原谅我无法使用stackoverflow ….这是我如何设法实现它,使用这两个这些UItablevIEwDelegate方法:
- (voID)tableVIEw:(UItableVIEw *)tableVIEw willdisplayheaderVIEw:(UIVIEw *)vIEw forSection:(NSInteger)section { if ([vIEw isMemberOfClass:[UItableVIEwheaderfooterVIEw class]]) { ((UItableVIEwheaderfooterVIEw *)vIEw).backgroundVIEw.backgroundcolor = [UIcolor clearcolor]; }}- (UIVIEw *)tableVIEw:(UItableVIEw *)tableVIEw vIEwForheaderInSection:(NSInteger)section { UItableVIEwheaderfooterVIEw *FeedheaderVIEw = [tableVIEw dequeueReusableheaderfooterVIEwWithIDentifIEr:@"headerIDentifIEr"]; //Other customizations return FeedheaderVIEw;}
希望有帮助,让我永远弄清楚.似乎backgroundVIEw不是在init中创建的,所以颜色不能被覆盖在那里.
总结以上是内存溢出为你收集整理的ios – 透明UITableViewHeaderFooterView全部内容,希望文章能够帮你解决ios – 透明UITableViewHeaderFooterView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)