Github源码推荐:(01.04):iOS开发蓝牙,启动动画,自定义Tabbar

Bison

"iOS开发蓝牙框架,以及酷炫的启动动画,还有低耦合的自定义的TabBar"


  • NO.1 国内最全面的iOS蓝牙开发框架━━∝∞ ∝∞┅┉┉下载

暂无效果图
具体用法如下

###中心模式 central model

app作为中心,连接其他BLE4.0外设

//导入.h文件和系统蓝牙库的头文件
#import "BabyBluetooth.h"
//定义变量
BabyBluetooth *baby;

-(void)viewDidLoad {
    [super viewDidLoad];

    //初始化BabyBluetooth 蓝牙库
    baby = [BabyBluetooth shareBabyBluetooth];
    //设置蓝牙委托
    [self babyDelegate];
    //设置委托后直接可以使用,无需等待CBCentralManagerStatePoweredOn状态
    baby.scanForPeripherals().begin();
}

//设置蓝牙委托
-(void)babyDelegate{

    //设置扫描到设备的委托
    [baby setBlockOnDiscoverToPeripherals:^(CBCentralManager *central, CBPeripheral *peripheral, NSDictionary *advertisementData, NSNumber *RSSI) {
        NSLog(@"搜索到了设备:%@",peripheral.name);
    }];

    //过滤器
    //设置查找设备的过滤器
    [baby setFilterOnDiscoverPeripherals:^BOOL(NSString *peripheralName) {
    //设置查找规则是名称大于1  the search rule is peripheral.name length > 1
    if (peripheralName.length >1) {
        return YES;
    }
        return NO;
    }];

//.......
}


//导入.h文件和系统蓝牙库的头文件
#import "BabyBluetooth.h"
//定义变量
BabyBluetooth *baby;

-(void)viewDidLoad {
    [super viewDidLoad];

    //配置第一个服务s1
    CBMutableService *s1 = makeCBService(@"FFF0");
    //配置s1的3个characteristic
    makeCharacteristicToService(s1, @"FFF1", @"r", @"hello1");//读
    makeCharacteristicToService(s1, @"FFF2", @"w", @"hello2");//写
    makeCharacteristicToService(s1, genUUID(), @"rw", @"hello3");//可读写,uuid自动生成
    makeCharacteristicToService(s1, @"FFF4", nil, @"hello4");//默认读写字段
    makeCharacteristicToService(s1, @"FFF5", @"n", @"hello5");//notify字段
    //配置第一个服务s2
    CBMutableService *s2 = makeCBService(@"FFE0");
    makeStaticCharacteristicToService(s2, genUUID(), @"hello6", [@"a" dataUsingEncoding:NSUTF8StringEncoding]);//一个含初值的字段,该字段权限只能是只读

    //实例化baby
    baby = [BabyBluetooth shareBabyBluetooth];
    //配置委托
    [self babyDelegate];
    //启动外设
    baby.bePeripheral().addServices(@[s1,s2]).startAdvertising();
}

//设置蓝牙外设模式的委托
-(void)babyDelegate{

    //设置添加service委托 | set didAddService block
    [baby peripheralModelBlockOnPeripheralManagerDidUpdateState:^(CBPeripheralManager *peripheral) {
    NSLog(@"PeripheralManager trun status code: %ld",(long)peripheral.state);
    }];

    //设置添加service委托 | set didAddService block
    [baby peripheralModelBlockOnDidStartAdvertising:^(CBPeripheralManager *peripheral, NSError *error) {
    NSLog(@"didStartAdvertising !!!");
    }];

    //设置添加service委托 | set didAddService block
    [baby peripheralModelBlockOnDidAddService:^(CBPeripheralManager *peripheral, CBService *service, NSError *error) {
    NSLog(@"Did Add Service uuid: %@ ",service.UUID);
    }];

//.....
}

###外设模式 peripheral model

app模拟一个,BLE4.0外设,可以被其他设备连接和使用
模拟一个有2个service和6个characteristic的外设


  • NO.2 炫酷的启动动画━━∝∞ ∝∞┅┉┉ 下载

    (allluckly.cn)

具体用法如下

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    //重点在这里
    [CLClipImageView addToCurrentView:self.view clipImage:[UIImage imageNamed:@"Default_image"] backgroundImage:@"" animationComplete:^{
        self.navigationController.navigationBarHidden = NO;
        [self makeTopView];
    }];
}


  • NO.3 低耦合的自定义的TabBar━━∝∞ ∝∞┅┉┉下载


(allluckly.cn)

具体用法请到下载页查看,作者写的非常的详细,在此不做任何的阐述

博主app上线啦,快点此来围观吧

更多经验请点击

好文推荐:Bison教你1分钟集成百度移动SSP启动广告

原文地址:http://allluckly.cn


分享文章