Data & networkingHistorical technical note
GitHub source-code picks, January 4: Bluetooth, launch animations and a custom tab bar
Selects the BabyBluetooth framework, CLClipImageView launch animation and CYLTabBarController tab bar. Project links and selected usage examples introduce the components, including the distinction between Bluetooth central and peripheral modes.
Historical resources collected by Bison. The listed projects belong to their respective authors.
On this page
“An iOS Bluetooth framework, an eye-catching launch animation, and a loosely coupled custom TabBar.”
- NO.1 The most comprehensive iOS Bluetooth development framework in China ━━∝∞ ∝∞┅┉┉Download
No preview image is available yet.
Usage is as follows.
Central mode: central model
The app acts as a central device and connects to other BLE4.0 peripherals.
//导入.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 mode: peripheral model
The app simulates a BLE4.0 peripheral that other devices can connect to and use.
Simulate a peripheral with 2 services and 6 characteristics.
- NO.2 An eye-catching launch animation ━━∝∞ ∝∞┅┉┉ Download

Usage is as follows.
- (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 A loosely coupled custom TabBar ━━∝∞ ∝∞┅┉┉Download
This historical illustration is currently unavailable. The original image URL is retained for reference.
See the download page for detailed usage. The author explains it thoroughly, so I will not repeat it here.
Recommended reading: Integrating a Baidu Mobile SSP launch ad in one minute
Original article: https://allluckly.cn/