You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

83 lines
2.2 KiB

//
// DeviceTableViewCell.m
// tongxin
//
// Created by ecell on 2022/11/9.
// Copyright © 2022 xTT. All rights reserved.
//
#import "DeviceTableViewCell.h"
#import "Bluetooth.h"
@interface DeviceTableViewCell ()
@property (nonatomic ,weak) UILabel *titleLabel;
@end
@implementation DeviceTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor clearColor];
[self subCellView];
}
return self;
}
- (void)setBleModel:(BLEModel *)bleModel
{
_bleModel = bleModel;
self.titleLabel.text = bleModel.peripheral.name;
}
- (void)subCellView
{
UILabel *titleLabel = [UILabel new];
self.titleLabel = titleLabel;
[self.contentView addSubview:titleLabel];
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.contentView);
make.left.equalTo(self.contentView).offset(15);
}];
UIButton *btn = [UIButton new];
[btn setTitle:@"连接设备" forState:0];
btn.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:Adapted(12)];
[btn setTitleColor:[UIColor whiteColor] forState:0];
btn.backgroundColor = mainColor;
btn.layer.cornerRadius = 3;
btn.layer.masksToBounds = YES;
[btn addTarget:self action:@selector(connectedBle) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:btn];
[btn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-15);
make.centerY.equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(Adapted(85), Adapted(28)));
}];
}
- (void)connectedBle
{
[UICommon MessageUpload:@"连接中..."];
[Bluetooth.shareInstance connectBLE:self.bleModel];
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end