AIDemo
<h3>這是一個(gè)使用三方庫(kù)的demo,其中有夜間模式曹动,放大圓圈轉(zhuǎn)場(chǎng),接入環(huán)信3.15實(shí)現(xiàn)單聊牲览,自動(dòng)隱藏navgationbar(可實(shí)現(xiàn)支付寶首頁(yè)效果)
github
夜間模式
夜間模式我使用的是DKNightVersion最新版本
設(shè)置顏色代碼
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(SEP);
設(shè)置圖片
UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height / 2.0, 50, 50 )];
imageV.dk_imagePicker = DKImagePickerWithNames(@"normal", @"night", @"normal1");
[self.view addSubview:imageV];
其中SEP是DKColorTable.txt
文件中的key墓陈。如果使用CocoaPods 導(dǎo)入,需要把DKColorTable.txt
文件拖到你工程里第献。想了解跟多了解可以看成熟的夜間模式解決方案
放大轉(zhuǎn)場(chǎng)動(dòng)畫
簡(jiǎn)單說(shuō)就是重寫
UINavigationControllerDelegate
協(xié)議里的方法返回一個(gè)自己定義的專場(chǎng)動(dòng)畫
- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC {
return (id)[AITransitionAnimator new];
}
下面是動(dòng)畫的實(shí)現(xiàn)
//得到登錄按鈕
UIButton *btn = keepView.loginButton;
[containerView addSubview:toVC.view];
UIBezierPath *originPath = [UIBezierPath bezierPathWithOvalInRect:btn.frame];
CGPoint extremePoint = CGPointMake(btn.center.x - 0, btn.center.y );//- CGRectGetHeight(toVC.view.bounds));
float radius = sqrtf(extremePoint.x * extremePoint.x + extremePoint.y * extremePoint.y);
UIBezierPath *finalPath = [UIBezierPath bezierPathWithOvalInRect:CGRectInset(btn.frame, -radius, -radius)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = finalPath.CGPath;
toVC.view.layer.mask = maskLayer;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
animation.fromValue = (__bridge id _Nullable)(originPath.CGPath);
animation.toValue = (__bridge id _Nullable)(finalPath.CGPath);
animation.duration = [self transitionDuration:transitionContext];
animation.delegate = self;
[maskLayer addAnimation:animation forKey:@"path"];
詳細(xì)的可以看HenryCheng的簡(jiǎn)書
環(huán)信3.15單聊
導(dǎo)入環(huán)信這些基本步驟我就不在這闡述了,目前的官方文檔還沒(méi)有跟新很多方法都沒(méi)有了贡必。我們直接導(dǎo)入
AppDelegate+EaseMob.h
。然后在AppDelegate
里加入
//環(huán)信
[self easemobApplication:application
didFinishLaunchingWithOptions:launchOptions
appkey:@"guozhongkeji#ckddemo"
apnsCertName:@"zhengshu"
otherConfig:nil];
// 登錄
EMError *error = [[EMClient sharedClient] loginWithUsername:@"text001" password:@"111"];
if (!error) {
NSLog(@"登錄成功");
}
appkey
和apnsCertName
當(dāng)然填寫自己的庸毫。(我的測(cè)試賬號(hào)111仔拟、222 兩個(gè)密碼都是000)
下一步把環(huán)信官方demo中的EaseUI
整個(gè)文件夾復(fù)制到你的工程下。你的單聊頁(yè)面只需要繼承EaseUI
里的EaseMessageViewController
飒赃,然后初始化的時(shí)候設(shè)置接收信息人的ID利花,push
過(guò)去就成功了!
//text002換成自己要發(fā)信息人的ID,注冊(cè)在環(huán)信開(kāi)發(fā)者中心-->我的應(yīng)用 IM用戶注冊(cè)就可以
AIChatSingleViewController *vc = [[AIChatSingleViewController alloc] initWithConversationChatter:@"text002" conversationType:EMConversationTypeChat];
這時(shí)候你已經(jīng)可以聊天了载佳,但是點(diǎn)擊表情的時(shí)候回發(fā)生崩潰炒事。解決方在EaseMessageViewController
這個(gè)文件中的viewdidload
方法最后加入
/**
* 修復(fù)環(huán)信表情崩潰
*/
EaseEmotionManager * manager = [[EaseEmotionManager alloc] initWithType:EMEmotionDefault emotionRow:3 emotionCol:7 emotions:[EaseEmoji allEmoji]];
[self.faceView setEmotionManagers:@[manager]];
圖標(biāo)3Dtouch
設(shè)置圖標(biāo)
- (void)setup3DTouch
{
UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"fx_3DTouch_AdorableStar"];
UIApplicationShortcutIcon *icon2 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"fx_3DTouch_Search_brand"];
UIApplicationShortcutIcon *icon3 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"fx_3DTouch_Receipt_of_goods"];
UIApplicationShortcutIcon *icon4 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"fx_3DTouch_Star_Ticket"];
UIMutableApplicationShortcutItem *item1 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.51fanxing.adorableStar" localizedTitle:@"萌星說(shuō)" localizedSubtitle:nil icon:icon1 userInfo:nil];
UIMutableApplicationShortcutItem *item2 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.51fanxing.searchBrand" localizedTitle:@"搜品牌" localizedSubtitle:nil icon:icon2 userInfo:nil];
UIMutableApplicationShortcutItem *item3 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.51fanxing.receiptOfGoods" localizedTitle:@"查物流" localizedSubtitle:nil icon:icon3 userInfo:nil];
UIMutableApplicationShortcutItem *item4 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.51fanxing.starTicket" localizedTitle:@"搖星券" localizedSubtitle:nil icon:icon4 userInfo:nil];
NSArray *items = @[item1, item2, item3,item4];
NSArray *existingItems = [UIApplication sharedApplication].shortcutItems;
NSArray *updatedItems = [existingItems arrayByAddingObjectsFromArray:items];
[UIApplication sharedApplication].shortcutItems = updatedItems;
}
通過(guò)3Dtouch進(jìn)來(lái)的時(shí)候
/**
* 通過(guò)3dtouch圖標(biāo)點(diǎn)進(jìn)來(lái)的時(shí)候
*
* @param application <#application description#>
* @param shortcutItem <#shortcutItem description#>
* @param completionHandler <#completionHandler description#>
*/
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void(^)(BOOL succeeded))completionHandler
{
[AIChooseRootVCTool chooseVCWithShortcutItem:shortcutItem];
}
自動(dòng)隱藏navgationbar
實(shí)際上他不是隱藏
navgationbar
而是自定義的一個(gè)view
//添加拉伸的bar
BLKFlexibleHeightBar *myBar = [[BLKFlexibleHeightBar alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, 100.0)];
myBar.minimumBarHeight = 50.0;
myBar.backgroundColor = [UIColor colorWithRed:0.86 green:0.25 blue:0.23 alpha:1];
[self.view addSubview:myBar];
myBar.behaviorDefiner = [SquareCashStyleBehaviorDefiner new];
[myBar.behaviorDefiner addSnappingPositionProgress:0.0 forProgressRangeStart:0.0 end:0.5];
[myBar.behaviorDefiner addSnappingPositionProgress:1.0 forProgressRangeStart:0.5 end:1.0];
myBar.behaviorDefiner.snappingEnabled = YES;
myBar.behaviorDefiner.elasticMaximumHeightAtTop = YES;
UILabel *label = [[UILabel alloc] init];
label.text = @"TrendyStartup.io";
label.font = [UIFont systemFontOfSize:25.0];
label.textColor = [UIColor blueColor];
[label sizeToFit];
//文字動(dòng)畫開(kāi)始狀態(tài)
BLKFlexibleHeightBarSubviewLayoutAttributes *initialLayoutAttributes = [BLKFlexibleHeightBarSubviewLayoutAttributes new];
initialLayoutAttributes.size = label.frame.size;
initialLayoutAttributes.center = CGPointMake(CGRectGetMidX(myBar.bounds), CGRectGetMidY(myBar.bounds)+10.0);
[label addLayoutAttributes:initialLayoutAttributes forProgress:0.0];
// Create a final set of layout attributes based on the same values as the initial layout attributes
//結(jié)束狀態(tài)(推上去狀態(tài))
BLKFlexibleHeightBarSubviewLayoutAttributes *finalLayoutAttributes = [[BLKFlexibleHeightBarSubviewLayoutAttributes alloc] initWithExistingLayoutAttributes:initialLayoutAttributes];
finalLayoutAttributes.alpha = 0.0;
CGAffineTransform translation = CGAffineTransformMakeTranslation(0.0, -30.0);
CGAffineTransform scale = CGAffineTransformMakeScale(0.2, 0.2);
finalLayoutAttributes.transform = CGAffineTransformConcat(scale, translation);
// This is what we want the bar to look like at its maximum height (progress == 0.0)
[label addLayoutAttributes:finalLayoutAttributes forProgress:1.0];
self.delegateSplitter = [[BLKDelegateSplitter alloc] initWithFirstDelegate:myBar.behaviorDefiner secondDelegate:self];
self.tabeleView.delegate = (id<UITableViewDelegate>)self.delegateSplitter;
[myBar addSubview:label];
設(shè)置最小高度改變這個(gè)值就可以myBar.minimumBarHeight = 50.0;
詳細(xì)的可以看BLKFlexibleHeightBar