開發小技巧總結

一、滑動的時候隱藏navigation  bargit

navigationController.hidesBarsOnSwipe = Yes;

 二、消除導航條返回鍵自帶的titlegithub

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
                                                 forBarMetrics:UIBarMetricsDefault];

 三、將導航條變得透明而不模糊app

[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                         forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar .shadowImage = [UIImage new];
self.navigationController.navigationBar .translucent = YES;

 四、拉伸圖片不變形ide

[[UIImage imageNamed:@""] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
[[UIImage imageNamed:@""] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];

 五、gif圖片顯示優化優化

FLAnimatedImage能夠幫你完成GIF的顯示處理。解決GIF顯示卡頓的狀況。blog

FLAnimatedImage *image = [FLAnimatedImage animatedImageWithGIFData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif"]]];
FLAnimatedImageView *imageView = [[FLAnimatedImageView alloc] init];
imageView.animatedImage = image;
imageView.frame = CGRectMake(0.0, 0.0, 100.0, 100.0);
[self.view addSubview:imageView];

 六、CollectionView實現tableview的懸停header圖片

CSStickyHeaderFlowLayout能夠解決您的疑問。ip

#import "CSStickyHeaderFlowLayout.h"
- (void)viewDidLoad {
 [super viewDidLoad]; // Locate your layout     
CSStickyHeaderFlowLayout *layout = (id)self.collectionViewLayout;
if ([layout isKindOfClass:[CSStickyHeaderFlowLayout class]]) { 
layout.parallaxHeaderReferenceSize = CGSizeMake(320, 200);
 } 
}


- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { // Check the kind if it's CSStickyHeaderParallaxHeader 
if ([kind isEqualToString:CSStickyHeaderParallaxHeader]) { 
UICollectionReusableView *cell = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"header" forIndexPath:indexPath];
 return cell; 
} 
}
相關文章
相關標籤/搜索