123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- //
- // previewLandscapeTopView.m
- // Private-X
- //
- // Created by xd h on 2024/7/10.
- //
- #import "previewLandscapeTopView.h"
- @interface previewLandscapeTopView ()
- @property(nonatomic,strong) UIButton*shareButton;
- @property(nonatomic,strong) UIButton*moreButton;
- @end
- @implementation previewLandscapeTopView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
- [self drawAnyView];
- return self;
- }
- - (void)drawAnyView{
-
- CGFloat curW = SCREEN_W;
- CGFloat curH = SCREEN_H;
- if(curW<curH){//横屏宽度最大
- curW = curH;
- }
-
- // gradient
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = CGRectMake(0,0,curW,60);
- gl.startPoint = CGPointMake(0.5, 0);
- gl.endPoint = CGPointMake(0.5, 1);
- gl.colors = @[(__bridge id)[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1.0].CGColor, (__bridge id)[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.0].CGColor];
- gl.locations = @[@(0), @(1.0f)];
- //[self.layer addSublayer:gl];
- [self.layer insertSublayer:gl atIndex:0];
-
- _backButton = [[UIButton alloc] init];
- _backButton.tag = 1;
- [_backButton setImage:[UIImage imageNamed:@"icon_white_back"] forState:(UIControlStateNormal)];
- [_backButton addTarget:self
- action:@selector(didClickButtonFun:)
- forControlEvents:(UIControlEventTouchUpInside)];
- [self addSubview:_backButton];
-
- [_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(10);
- make.width.mas_equalTo(60);
- make.height.mas_equalTo(60);
- }];
-
- _moreButton = [[UIButton alloc] init];
- _moreButton.tag = 2;
- [_moreButton setImage:[UIImage imageNamed:@"nas_preview_more_white"] forState:(UIControlStateNormal)];
- [_moreButton addTarget:self
- action:@selector(didClickButtonFun:)
- forControlEvents:(UIControlEventTouchUpInside)];
- [self addSubview:_moreButton];
-
- [_moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.right.mas_equalTo(-10);
- make.width.mas_equalTo(60);
- make.height.mas_equalTo(60);
- }];
-
-
- _shareButton = [[UIButton alloc] init];
- _shareButton.tag = 3;
- [_shareButton setImage:[UIImage imageNamed:@"nas_preview_share_white"] forState:(UIControlStateNormal)];
- [_shareButton addTarget:self
- action:@selector(didClickButtonFun:)
- forControlEvents:(UIControlEventTouchUpInside)];
- [self addSubview:_shareButton];
-
- [_shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.right.equalTo(_moreButton.mas_left).offset(0);
- make.width.mas_equalTo(60);
- make.height.mas_equalTo(60);
- }];
-
-
- _titleLabel = [[UILabel alloc] init];
- [_titleLabel setTextColor:[UIColor whiteColor]];
- [_titleLabel setFont:[UIFont boldSystemFontOfSize:18.f]];
- _titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
- [self addSubview:_titleLabel];
- [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.mas_centerY);
- make.left.equalTo(_backButton.mas_right).offset(10);
- make.right.equalTo(_shareButton.mas_left).offset(-10);
- //make.height.mas_equalTo(25);
- }];
-
- }
- #pragma mark 按钮点击事件
- - (void)didClickButtonFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
-
- if(_didClickButton){
- _didClickButton(tag);
- }
- }
- @end
|