Skip to content

Instantly share code, notes, and snippets.

@gliubc
gliubc / .m
Last active September 23, 2021 07:50
- (void)layoutSubviews {
[super layoutSubviews];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.shopLabel.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *shape = [CAShapeLayer new];
[shape setPath:maskPath.CGPath];
self.shopLabel.layer.mask = shape;
}
@gliubc
gliubc / .swift
Created September 10, 2021 03:10
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
let shapeLayer = CAShapeLayer()
shapeLayer.strokeColor = UIColor(rgb: 0xEEEEEE).cgColor
shapeLayer.lineWidth = 1
// passing an array with the values [2,3] sets a dash pattern that alternates between a 2-user-space-unit-long painted segment and a 3-user-space-unit-long unpainted segment
shapeLayer.lineDashPattern = [2,3]
@gliubc
gliubc / .m
Created September 19, 2020 03:40
if (@available(iOS 11, *)) {
// Use iOS 11 APIs.
} else {
// Alternative code for earlier versions of iOS.
}
@gliubc
gliubc / name
Last active September 23, 2020 08:32
Application
Extensions
Categories
Utils
Controllers
@gliubc
gliubc / .m
Created December 21, 2019 00:09
// 视图自适应屏幕宽度
CGRect frame = self.view.frame;
frame.size.width = UIScreen.mainScreen.bounds.size.width;
self.view.frame = frame;
[self.view layoutIfNeeded];
// 单元格自适应屏幕宽度
CGRect frame = self.frame;
frame.size.width = UIScreen.mainScreen.bounds.size.width;
self.frame = frame;
@gliubc
gliubc / .txt
Last active September 23, 2020 08:32
- 优化产品体验
- 修复了一些问题
https://www.liuniukeji.com
2019 Liuniu Inc
@gliubc
gliubc / .m
Last active November 22, 2019 01:37
// 监听通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveCartDataChangedNotification:) name:@"CartDataChangedNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveAlipayResultNotification:) name:@"AlipayResultNotification" object:nil];
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
/// 接收到购物车数据改变
@gliubc
gliubc / .m
Last active November 26, 2019 05:42
UIScrollView *scrollView = UIScrollView.new;
for (UIView *view in [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(Test1VC.class) owner:self options:nil]) {
[scrollView addSubview:view];
view.frame = CGRectMake(0, scrollView.contentSize.height, view.frame.size.width, view.frame.size.height);
scrollView.contentSize = CGSizeMake(view.frame.size.width, scrollView.contentSize.height + view.frame.size.height);
}
self.view = scrollView;
@gliubc
gliubc / .m
Last active September 12, 2019 06:15
- (void)upgrade {
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSString *url = @"Api/PublicApi/getVersion";
NSMutableDictionary *params = [NSMutableDictionary new];
[[[LNNetWorkAPI alloc] initWithUrl:url parameters:params] startWithBlockSuccess:^(__kindof LCBaseRequest *request) {
[SVProgressHUD dismiss];
id json = request.responseJSONObject;
if ([json[@"status"] integerValue] != 1) {
@gliubc
gliubc / .m
Created August 19, 2019 05:50
[[SDWebImageManager sharedManager] loadImageWithURL:FullImageUrl(self.model.goods_gallery.firstObject.image_path) options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
}];