Skip to content

Instantly share code, notes, and snippets.

View hanfengs's full-sized avatar

hanfengs

  • Beijing China
View GitHub Profile
@hanfengs
hanfengs / alert.m
Created July 27, 2022 07:21
[优惠券弹框]
/// 根据接口是否显示优惠券弹框
[self showCouponAlertView];
#pragma mark- 优惠弹框
- (void)showCouponAlertView {
UIView *contentView = [[UIView alloc] initWithFrame:CGRectZero];
contentView.backgroundColor = UIColorRed;
@hanfengs
hanfengs / draw.m
Created July 21, 2022 03:35
[族谱布局连线]#绘制
////
- (void)setupUI {
UIView *lastOne = nil;
NSInteger count = 16;
for (NSInteger i = 0; i < count; i++) {
SYPersonGraphOneManView *one = [[SYPersonGraphOneManView alloc] init];
@hanfengs
hanfengs / border.swift
Last active January 14, 2022 08:45
[文字描边] #swift
//https://www.jianshu.com/p/5c3883bdfd7e
let startLabel = UICreateTools.createLabel(frame: .zero, text: "string_start".localization, font: UIFont.mainFont(size: 12, weight: .heavy), textColor: .white, alignment: .right)
// startLabel.addBorder(1, color: UIColor(red: 62, green: 0, blue: 255))
self.view.addSubview(startLabel)
startLabel.snp.makeConstraints { make in
make.centerY.equalTo(startDate24Button)
make.trailing.equalTo(startDate24Button.snp.leading).offset(-4)
}
@hanfengs
hanfengs / push.swift
Last active December 22, 2021 03:19
[swift推送的处理] #swift
-------------------------------------------------------
// push receive 情况
if topVC is LiveShowDetailController && LiveShowService.shared.currentChannel?.host.id == AuthAccount.current?.id{
canDisplay = false
}
if topVC is MainTabViewController {
if let child = UIApplication.getChildViewController(parent: topVC), child is LiveShowDetailController {
@hanfengs
hanfengs / grad.swift
Last active December 22, 2021 03:16
[swift渐变色] #swift
let layer = CAGradientLayer()
layer.frame = self.tabBarBottomView.bounds
layer.startPoint = CGPoint.zero
layer.endPoint = CGPoint(x: 0, y: 1)
layer.colors = [UIColor(red: 78, green: 78, blue: 78, transparency: 0).cgColor, UIColor(red: 0, green: 0, blue: 0, transparency: 0.5).cgColor]
self.tabBarBottomView.layer.addSublayer(layer)
@hanfengs
hanfengs / date.swift
Last active December 17, 2021 08:32
[date相关]
//这个以 utc +0000
服务器是 utc 0 的时间
config的配置信息里也是 utc 0 时间(关键这里是计算出来的,当前时间零点+start)
所以此刻,所有人的倒计时都应该是一样的
@hanfengs
hanfengs / lottie.swift
Last active December 17, 2021 07:17
[Lottie相关]
// https://juejin.cn/post/6844904007769522183
override func viewDidLoad() {
super.viewDidLoad()
lottieView.frame = CGRect(x: 0, y: 0, width: 400, height: 400)
lottieView.center = self.view.center
lottieView.animation = Animation.named(“lottieJson“)//绑定Lottie动画
lottieView.loopMode = .loop//动画效果 执行单次、多次
lottieView.contentMode = .scaleAspectFit
@hanfengs
hanfengs / badge.swift
Created December 15, 2021 09:07
[清理角标和通知]
// iOS App如何清除badge并保留通知中心的消息
//https://medium.com/@jasonyuh/ios-app%E5%A6%82%E4%BD%95%E6%B8%85%E9%99%A4badge%E5%B9%B6%E4%BF%9D%E7%95%99%E9%80%9A%E7%9F%A5%E4%B8%AD%E5%BF%83%E7%9A%84%E6%B6%88%E6%81%AF-e4d9f35f9ef5
//https://www.jianshu.com/p/59878fd8053c
func applicationDidBecomeActive(_ application: UIApplication) {
// MARK: 角标重置
application.applicationIconBadgeNumber = -1
// MARK: 移除所有远程通知
@hanfengs
hanfengs / attr.swift
Created December 15, 2021 07:11
[swift的AttributedString用法]
let descString = "delete_account_check_des".localization as NSString
let range = descString.range(of: "DELETE")
let attributes = NSMutableAttributedString(string: descString as String)
attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(red: 255, green: 0, blue: 8), range: range)
deleteTyptDescLable.attributedText = attributes
@hanfengs
hanfengs / auth.swift
Last active December 14, 2021 03:50
[swift权限]
// https://juejin.cn/post/6844904142045970445#heading-2
func notificationAuthorization() {
let camera = AVCaptureDevice.authorizationStatus(for: .video)
if camera == .notDetermined {
return
}
let location = CLLocationManager.authorizationStatus()
if location == .notDetermined {