1.MarqueeLabel
主要用來超長文本自動滾動顯示的
MarqueeLabel *marqueeLabel = [[MarqueeLabel alloc]initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, 50) duration:9 andFadeLength:65.0];
[marqueeLabel setTextColor:[UIColor whiteColor]];
[marqueeLabel setText:contentStr];
marqueeLabel.marqueeType = MLContinuous;
marqueeLabel.animationCurve = UIViewAnimationOptionCurveEaseInOut;
[self.view addSubview:marqueeLabel];
2.WebViewJavascriptBridge
在iOS6之前這個框架一直用著很好悠咱,iOS7以后蘋果引用了JavaScriptCore框架寡具,非常好用前计,然而我還沒有會用,如果你的App需要兼容iOS6之前系統(tǒng)WebViewJavascriptBridge還是很好用的
使用cocoaPods導入WebViewJavascriptBridge時自動引入了jsonkit框架,編譯的時候一堆關于isa的報錯疚脐,只要按照報錯提示改了就可以了征候,WebViewJavascriptBridge具體使用在網(wǎng)上一搜都是用法
/****現(xiàn)將webView與WebViewJavascriptBridge建立好關聯(lián)***/
if (_bridge) {
return;
}
_webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
_webView.scrollView.scrollEnabled = YES;
_webView.delegate = self;
_webView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:_webView];
[WebViewJavascriptBridge enableLogging];
_bridge = [WebViewJavascriptBridge bridgeForWebView:_webView webViewDelegate:self handler:^(id data, WVJBResponseCallback responseCallback) {
responseCallback(@"success");
}];
/***雙方的溝通***/
js調(diào)用oc代碼匠襟,雙方定義好方法名testObjcCallback
[_bridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) {
NSLog(@"testObjcCallback called: %@", data);//data為js傳過來的值
responseCallback(@"Response from testObjcCallback");//向js回傳
}];
oc調(diào)用js代碼
id data = @{ @"33333": @"4554554554" };
[_bridge callHandler:@"testJavascriptHandler" data:data responseCallback:^(id response) {
NSLog(@"testJavascriptHandler 33333 responded: %@", response);//通過response可以接受js那邊的返回值
}];
oc向js穿值
//需要返回值
[_bridge send:@"1111111" responseCallback:^(id response) {
NSLog(@"222222: %@", response);//response接受返回值
}];
//不需要返回值
[_bridge send:@"A string sent from ObjC after Webview has loaded."];
demo地址:https://github.com/tuwanli/WEBInteraction
3.HMSegmentedControl
用來做頁面切換的
先看下效果
舉個小例子
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_titleArr = @[@"標題一",@"標題二",@"標題三",@"標題四",@"標題五",@"標題六",@"標題七",@"標題八"];
self.view.backgroundColor = [UIColor whiteColor];
UIView *headerView =[[UIView alloc]initWithFrame:CGRectMake(0, self.view.bounds.size.height-100, [UIScreen mainScreen].bounds.size.width, 40)];
[self.view addSubview:headerView];
_segmentControl = [[HMSegmentedControl alloc]initWithSectionTitles:_titleArr];
_segmentControl.autoresizingMask = UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleWidth;
_segmentControl.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 40);
_segmentControl.selectionStyle = HMSegmentedControlSelectionStyleFullWidthStripe;
_segmentControl.backgroundColor = [UIColor clearColor];
_segmentControl.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:14]};
_segmentControl.selectionIndicatorHeight = 3.0f;
_segmentControl.selectionIndicatorColor = [UIColor whiteColor];
_segmentControl.selectedTitleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:14]};
_segmentControl.selectionStyle = HMSegmentedControlSelectionStyleFullWidthStripe;
_segmentControl.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown;
[_segmentControl addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];
_segmentControl.shouldScrollFlag = YES;
_segmentControl.backgroundColor = [UIColor redColor];
_segmentControl.selectedSegmentIndex = 0;
[headerView addSubview:_segmentControl];
//? ? [self.view addSubview:_segmentControl];
_scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, self.view.bounds.size.height-60, self.view.bounds.size.width, 60)];
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.contentSize = CGSizeMake(_titleArr.count*[UIScreen mainScreen].bounds.size.width, 0);
_scrollView.pagingEnabled = YES;
_scrollView.delegate = self;
[self.view addSubview:_scrollView];
CGFloat width = self.view.bounds.size.width-10;
for (int i=0; i<_titleArr.count; i++) {
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(5*(2*i+1)+width*i, 0,width, 60)];
view.backgroundColor = [UIColor purpleColor];
[_scrollView addSubview:view];
}
}
#pragma mark - 頂層的類的點擊事件
- (void)segmentedControlChangedValue:(HMSegmentedControl *)segmentedControl
{
if (_currentIndex != segmentedControl.selectedSegmentIndex) {
[_scrollView setContentOffset:CGPointMake((_scrollView.frame.size.width) * segmentedControl.selectedSegmentIndex, 0) animated:YES];
_currentIndex = segmentedControl.selectedSegmentIndex;
}
}
4.SDCycleScrollView
這個大部分人都用過吧,用來做無限輪播的脱柱,也很好用伐弹,這個網(wǎng)上很多說明的具體不多說了
5.RatingBar
用來評論星級
代碼很簡單
RatingBar *ratingBar = [[RatingBar alloc] initWithFrame:CGRectMake(100, self.view.bounds.size.height-200, 20 * 5 + 12.5 * 4, 20)];
ratingBar.isIndicator = NO;
[ratingBar setImageDeselected:@"inquiry_star_normal" halfSelected:nil fullSelected:@"inquiry_star_click" andDelegate:self];
[self.view addSubview:ratingBar];
6.RFViewController
UICollectionView的一種布局,具體的看看吧https://github.com/tuwanli/RFQuiltLayout
7.SMPageControl
自定義UIPageControl的外觀榨为,包括形狀惨好、大小、間距等柠逞,也可以用圖片代替UIPageControl上的小圓點昧狮。http://www.oschina.net/p/SMPageControl
8.OHAlertView/STAlertView
彈框效果:https://github.com/AliSoftware/OHAlertView-OHActionSheet//OHAlertView
http://www.oschina.net/p/stalertview/similar_projects//STAlertView
9.ViewDeck
https://github.com/tuwanli/ViewDeck左右滑出菜單控件
10.appirater
提示用戶評分:https://github.com/tuwanli/appirater
11.PaperFold作的iOS
滑動折疊的效果https://github.com/tuwanli/PaperFold-for-iOS
12.TSMessages
*信息提示**https://github.com/toursprung/TSMessages
13. MGBox2
https://github.com/tuwanli/MGBoxKit
*簡單,快速的iOS表格板壮,網(wǎng)格
14.[MWPhotoBrowser
https://github.com/mwaterfall/MWPhotoBrowser圖片瀏覽器
15.OHAttributedLabel
*富文本標簽https://github.com/AliSoftware/OHAttributedLabel
16. DCRoundSwitch
*自定義的UISwitch?https://github.com/domesticcatsoftware/DCRoundSwitch