phizclip-ios-demo/FinDemo/功能演示/3.UI样式自定义/FinCustomUIViewController.m

73 lines
2.1 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//
// FinCustomUIViewController.m
// FinDemo
//
// Created by 胡健辉 on 2023/5/30.
//
#import "FinCustomUIViewController.h"
#import <FinApplet/FinApplet.h>
//需要继承FATBaseLoadingView
@interface LoadingView : FATBaseLoadingView
@end
@implementation LoadingView
- (void)layoutSubviews {
[super layoutSubviews];
//修改小程序标题的颜色
self.titleLabel.textColor = [UIColor redColor];
//修改loading页的logo
self.loadingView.iconImageView.image = [UIImage imageNamed:@"AppIcon"];
}
@end
@implementation FinCustomUIViewController
/*
详情参考https://www.finclip.com/mop/document/runtime-sdk/custom-ui/set-loading.html
*/
- (instancetype)init {
if (self = [super init]) {
//在有缓存的情况下loading页面可能会一闪而逝所以这里先清除缓存方便观察
[[FATClient sharedClient] clearMemoryCache];
[[FATClient sharedClient] clearLocalApplets];
//自定义loading页面的样式
[FATClient sharedClient].config.baseLoadingViewClass = @"LoadingView";
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = UIColor.whiteColor;
UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 300, 40)];
[button setTitle: NSLocalizedString(@"打开小程序", nil) forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
button.center = self.view.center;
}
- (void)click {
FATAppletRequest *request = [[FATAppletRequest alloc] init];
request.appletId = @"5f72e3559a6a7900019b5baa";//微信官方小程序
[[FATClient sharedClient] startAppletWithRequest:request InParentViewController:self completion:nil closeCompletion:nil];
}
- (void)dealloc {
//取消自定义样式
[FATClient sharedClient].config.baseLoadingViewClass = nil;
}
@end