Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f2f5c4e

Browse files
Project_RootViewController - 删改代码
1 parent 59ad4b1 commit f2f5c4e

File tree

1 file changed

+96
-201
lines changed

1 file changed

+96
-201
lines changed

‎Coding_iOS/Controllers/RootControllers/Project_RootViewController.m‎

Lines changed: 96 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -90,36 +90,10 @@ - (void)viewDidLoad
9090
icarousel.bounceDistance = 0.2;
9191
[self.view addSubview:icarousel];
9292
[icarousel mas_makeConstraints:^(MASConstraintMaker *make) {
93-
// make.left.right.bottom.equalTo(self.view);
94-
// make.top.equalTo(self.view).offset(kMySegmentControl_Height);
9593
make.edges.equalTo(self.view);
9694
}];
9795
icarousel;
9896
});
99-
100-
// //添加搜索框
101-
// _mySearchBar = ({
102-
// UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0,0, kScreen_Width-110, 31)];
103-
// searchBar.layer.cornerRadius=15;
104-
// searchBar.layer.masksToBounds=TRUE;
105-
// [searchBar.layer setBorderWidth:8];
106-
// [searchBar.layer setBorderColor:[UIColor whiteColor].CGColor]; //设置边框为白色
107-
// [searchBar sizeToFit];
108-
// searchBar.delegate = self;
109-
// [searchBar setPlaceholder:@"项目/任务/讨论/冒泡等"];
110-
// UITextField *searchField= [[[[searchBar subviews] firstObject] subviews] lastObject];
111-
//// [searchField setHeight:22];
112-
//// searchField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
113-
//// [searchField setBackgroundColor:[UIColor blueColor]];
114-
// [(UIImageView*)[searchField leftView] setFrame:CGRectMake(0, 0, 13, 13)];
115-
// [(UIImageView*)[searchField leftView] setImage:[UIImage imageNamed:@"icon_search_searchbar"]];
116-
// [searchBar setImage:[UIImage imageNamed:@"icon_search_searchbar"] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
117-
// [searchBar setTintColor:[UIColor whiteColor]];
118-
// [searchBar insertBGColor:[UIColor colorWithHexString:@"0x28303b"]];
119-
// [searchBar setHeight:31];
120-
// searchBar;
121-
// });
122-
12397
//添加搜索框
12498
_mySearchBar = ({
12599
MainSearchBar *searchBar = [[MainSearchBar alloc] initWithFrame:CGRectMake(60,7, kScreen_Width-115, 31)];
@@ -132,26 +106,13 @@ - (void)viewDidLoad
132106
[searchBar sizeToFit];
133107
[searchBar setTintColor:[UIColor whiteColor]];
134108
[searchBar insertBGColor:[UIColor colorWithHexString:@"0xffffff"]];
135-
// [searchBar setImage:nil forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
136-
// [searchBar setPositionAdjustment:UIOffsetMake(10,0) forSearchBarIcon:UISearchBarIconClear];
137-
// searchBar.searchTextPositionAdjustment=UIOffsetMake(10,0);
138109
[searchBar setHeight:30];
139110
searchBar;
140111
});
141-
142-
143-
// _searchView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width-110, 31)];//allocate titleView
144-
// UIColor *color = [UIColor colorWithHexString:[NSObject baseURLStrIsTest]? @"0x3bbd79" : @"0x28303b"];
145-
// [_searchView setBackgroundColor:color];
146-
147-
148-
149112
__weak typeof(_myCarousel) weakCarousel = _myCarousel;
150113

151114
//初始化过滤目录
152115
_myFliterMenu = [[PopFliterMenu alloc] initWithFrame:CGRectMake(0, 64, kScreen_Width, kScreen_Height-64) items:nil];
153-
// _myFliterMenu = [[PopFliterMenu alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height) items:nil];
154-
155116
__weak typeof(self) weakSelf = self;
156117
_myFliterMenu.clickBlock = ^(NSInteger pageIndex){
157118
if (pageIndex==1000) {
@@ -219,15 +180,43 @@ - (void)viewDidLoad
219180
self.icarouselScrollEnabled = NO;
220181
}
221182

183+
- (void)viewWillAppear:(BOOL)animated{
184+
[super viewWillAppear:animated];
185+
[self.navigationController.navigationBar addSubview:_mySearchBar];
186+
if (_myCarousel) {
187+
ProjectListView *listView = (ProjectListView *)_myCarousel.currentItemView;
188+
if (listView) {
189+
[listView refreshToQueryData];
190+
}
191+
}
192+
[_myFliterMenu refreshMenuDate];
193+
}
194+
195+
-(void)viewWillDisappear:(BOOL)animated
196+
{
197+
[super viewWillDisappear:animated];
198+
[_mySearchBar removeFromSuperview];
199+
}
200+
201+
- (void)viewDidAppear:(BOOL)animated{
202+
[super viewDidAppear:animated];
203+
[[UnReadManager shareManager] updateUnRead];
204+
}
205+
206+
#pragma mark - sub class method
222207
- (void)setIcarouselScrollEnabled:(BOOL)icarouselScrollEnabled{
223208
_myCarousel.scrollEnabled = icarouselScrollEnabled;
224209
}
225210

211+
- (void)configSegmentItems{
212+
_segmentItems = @[@"全部项目",@"我创建的", @"我参与的",@"我关注的",@"我收藏的"];
213+
}
214+
215+
#pragma mark - nav item
226216
- (void)setupNavBtn{
227217

228218
_leftNavBtn=[UIButton new];
229219
[self addImageBarButtonWithImageName:@"filtertBtn_normal_Nav" button:_leftNavBtn action:@selector(fliterClicked:) isRight:NO];
230-
231220
//变化按钮
232221
_rightNavBtn = [[FRDLivelyButton alloc] initWithFrame:CGRectMake(0,0,18.5,18.5)];
233222
[_rightNavBtn setOptions:@{ kFRDLivelyButtonLineWidth: @(1.0f),
@@ -237,60 +226,84 @@ - (void)setupNavBtn{
237226
[_rightNavBtn addTarget:self action:@selector(addItemClicked:) forControlEvents:UIControlEventTouchUpInside];
238227
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:_rightNavBtn];
239228
self.navigationItem.rightBarButtonItem = buttonItem;
240-
241-
// __weak typeof(_myCarousel) weakCarousel = _myCarousel;
242-
243-
//添加滑块
244-
// _mySegmentControl = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kMySegmentControl_Height) Items:_segmentItems selectedBlock:^(NSInteger index) {
245-
// if (index == _oldSelectedIndex) {
246-
// return;
247-
// }
248-
// [weakCarousel scrollToItemAtIndex:index animated:NO];
249-
// }];
250-
// [self.view addSubview:_mySegmentControl];
251-
252-
253-
// [self addImageBarButtonWithImageName:@"addBtn_Nav" button:_rightNavBtn action:@selector(addItemClicked:) isRight:YES];
254-
255229
}
256230

257-
- (void)configSegmentItems{
258-
_segmentItems = @[@"全部项目",@"我创建的", @"我参与的",@"我关注的",@"我收藏的"];
231+
-(void)addItemClicked:(id)sender{
232+
if (_rightNavBtn.buttonStyle == kFRDLivelyButtonStylePlus) {
233+
[_rightNavBtn setStyle:kFRDLivelyButtonStyleClose animated:YES];
234+
[_myPopMenu showMenuAtView:kKeyWindow startPoint:CGPointMake(0, -100) endPoint:CGPointMake(0, -100)];
235+
} else{
236+
[_myPopMenu dismissMenu];
237+
}
259238
}
260239

261-
- (void)viewWillAppear:(BOOL)animated{
262-
[super viewWillAppear:animated];
263-
// [self.navigationItem.titleView sizeToFit];
264-
// [_searchView addSubview:_mySearchBar];
265-
// self.navigationItem.titleView = _searchView;
240+
-(void)fliterClicked:(id)sender{
241+
[self closeMenu];
242+
if (_myFliterMenu.showStatus) {
243+
[self fliterBtnClose:TRUE];
244+
[_myFliterMenu dismissMenu];
245+
}else
246+
{
247+
[self fliterBtnClose:FALSE];
248+
_myFliterMenu.selectNum=_selectNum>=3?_selectNum+1:_selectNum;
249+
UIView *presentView=[[[UIApplication sharedApplication].keyWindow rootViewController] view];
250+
[_myFliterMenu showMenuAtView:presentView];
251+
}
252+
}
266253

267-
[self.navigationController.navigationBar addSubview:_mySearchBar];
254+
-(void)closeFliter{
255+
if ([_myFliterMenu showStatus]) {
256+
[_myFliterMenu dismissMenu];
257+
[self fliterBtnClose:TRUE];
258+
}
259+
}
268260

269-
270-
if (_myCarousel) {
271-
ProjectListView *listView = (ProjectListView *)_myCarousel.currentItemView;
272-
if (listView) {
273-
[listView refreshToQueryData];
274-
}
261+
-(void)closeMenu{
262+
if ([_myPopMenu isShowed]) {
263+
[_rightNavBtn setStyle:kFRDLivelyButtonStylePlus animated:YES];
264+
[_myPopMenu dismissMenu];
275265
}
276-
[_myFliterMenu refreshMenuDate];
277266
}
278267

279-
-(void)viewWillDisappear:(BOOL)animated
280-
{
281-
[super viewWillDisappear:animated];
282-
[_mySearchBar removeFromSuperview];
268+
-(void)fliterBtnClose:(BOOL)status{
269+
[_leftNavBtn setImage:status?[UIImage imageNamed:@"filtertBtn_normal_Nav"]:[UIImage imageNamed:@"filterBtn_selected_Nav"] forState:UIControlStateNormal];
283270
}
284271

285-
- (void)viewDidAppear:(BOOL)animated{
286-
[super viewDidAppear:animated];
287-
[[UnReadManager shareManager] updateUnRead];
272+
//弹出事件
273+
-(void)rotateView:(UIView*)aView
274+
{
275+
POPBasicAnimation* rotateAnimation = ({
276+
POPBasicAnimation* basicAnimation=[POPBasicAnimation animationWithPropertyNamed:kPOPLayerRotation];
277+
basicAnimation.toValue = @(22.5 * (M_PI / 180.0f));
278+
basicAnimation.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
279+
basicAnimation.duration = 0.2f;
280+
[basicAnimation setCompletionBlock:^(POPAnimation * ani, BOOL fin) {
281+
if (fin) {
282+
}
283+
}];
284+
basicAnimation;
285+
});
286+
[aView.layer pop_addAnimation:rotateAnimation forKey:@"rotateAnimation"];
288287
}
289288

290-
-(void)didReceiveMemoryWarning
289+
-(void)addImageBarButtonWithImageName:(NSString*)imageNamebutton:(UIButton*)aBtnaction:(SEL)actionisRight:(BOOL)isR
291290
{
292-
[super didReceiveMemoryWarning];
293-
// Dispose of any resources that can be recreated.
291+
UIImage *image = [UIImage imageNamed:imageName];
292+
CGRect frame = CGRectMake(0,0, image.size.width, image.size.height);
293+
294+
aBtn.frame=frame;
295+
[aBtn setImage:image forState:UIControlStateNormal];
296+
[aBtn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
297+
298+
UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aBtn];
299+
300+
if (isR)
301+
{
302+
[self.navigationItem setRightBarButtonItem:barButtonItem];
303+
}else
304+
{
305+
[self.navigationItem setLeftBarButtonItem:barButtonItem];
306+
}
294307
}
295308

296309
#pragma mark iCarousel M
@@ -369,23 +382,6 @@ - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel
369382
}
370383

371384
#pragma mark VC
372-
-(void)addItemClicked:(id)sender{
373-
[self closeFliter];
374-
if (_rightNavBtn.buttonStyle == kFRDLivelyButtonStylePlus) {
375-
[_rightNavBtn setStyle:kFRDLivelyButtonStyleClose animated:YES];
376-
UIView *presentView=[[[UIApplication sharedApplication].keyWindow rootViewController] view];
377-
// [presentView bringSubviewToFront:[presentView.subviews firstObject]];
378-
// [_myPopMenu showMenuAtView:self.view startPoint:CGPointMake(0, -100) endPoint:CGPointMake(0, -100) withTabFooterView:presentView];
379-
// [_myPopMenu showMenuAtView:self.view startPoint:CGPointMake(0, -100) endPoint:CGPointMake(0, -100)];
380-
[_myPopMenu showMenuAtView:presentView startPoint:CGPointMake(0, -100) endPoint:CGPointMake(0, -100)];
381-
382-
383-
} else{
384-
[_rightNavBtn setStyle:kFRDLivelyButtonStylePlus animated:YES];
385-
[_myPopMenu dismissMenu];
386-
}
387-
}
388-
389385
- (void)goToNewProjectVC{
390386
UIStoryboard *newProjectStoryboard = [UIStoryboard storyboardWithName:@"NewProject" bundle:nil];
391387
UIViewController *newProjectVC = [newProjectStoryboard instantiateViewControllerWithIdentifier:@"NewProjectVC"];
@@ -440,97 +436,6 @@ - (void)goToProjectSquareVC{
440436
[self.navigationController pushViewController:vc animated:YES];
441437
}
442438

443-
444-
-(void)closeFliter{
445-
if ([_myFliterMenu showStatus]) {
446-
[_myFliterMenu dismissMenu];
447-
[self fliterBtnClose:TRUE];
448-
}
449-
}
450-
451-
-(void)closeMenu{
452-
if ([_myPopMenu isShowed]) {
453-
[_rightNavBtn setStyle:kFRDLivelyButtonStylePlus animated:YES];
454-
[_myPopMenu dismissMenu];
455-
}
456-
}
457-
458-
-(void)fliterBtnClose:(BOOL)status{
459-
[_leftNavBtn setImage:status?[UIImage imageNamed:@"filtertBtn_normal_Nav"]:[UIImage imageNamed:@"filterBtn_selected_Nav"] forState:UIControlStateNormal];
460-
}
461-
462-
//弹出事件
463-
-(void)rotateView:(UIView*)aView
464-
{
465-
POPBasicAnimation* rotateAnimation = ({
466-
POPBasicAnimation* basicAnimation=[POPBasicAnimation animationWithPropertyNamed:kPOPLayerRotation];
467-
basicAnimation.toValue = @(22.5 * (M_PI / 180.0f));
468-
basicAnimation.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
469-
basicAnimation.duration = 0.2f;
470-
[basicAnimation setCompletionBlock:^(POPAnimation * ani, BOOL fin) {
471-
if (fin) {
472-
}
473-
}];
474-
basicAnimation;
475-
});
476-
[aView.layer pop_addAnimation:rotateAnimation forKey:@"rotateAnimation"];
477-
478-
479-
480-
// [UIView beginAnimations:nil context:nil];
481-
// [UIView setAnimationDuration:0.2];
482-
// [UIView setAnimationDelegate:self];
483-
// aView.transform = CGAffineTransformMakeRotation(22.5 * (M_PI / 180.0f));
484-
// [UIView commitAnimations];
485-
486-
}
487-
488-
-(void)addImageBarButtonWithImageName:(NSString*)imageName button:(UIButton*)aBtn action:(SEL)action isRight:(BOOL)isR
489-
{
490-
UIImage *image = [UIImage imageNamed:imageName];
491-
CGRect frame = CGRectMake(0,0, image.size.width, image.size.height);
492-
493-
aBtn.frame=frame;
494-
[aBtn setImage:image forState:UIControlStateNormal];
495-
[aBtn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
496-
497-
UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:aBtn];
498-
499-
if (isR)
500-
{
501-
[self.navigationItem setRightBarButtonItem:barButtonItem];
502-
}else
503-
{
504-
[self.navigationItem setLeftBarButtonItem:barButtonItem];
505-
}
506-
}
507-
508-
509-
510-
511-
#pragma mark fliter
512-
-(void)fliterClicked:(id)sender{
513-
[self closeMenu];
514-
if (_myFliterMenu.showStatus) {
515-
[self fliterBtnClose:TRUE];
516-
// UIView *presentView=[[[UIApplication sharedApplication].keyWindow rootViewController] view];
517-
// if ([[presentView.subviews firstObject] isMemberOfClass:NSClassFromString(@"RDVTabBar")]) {
518-
// [presentView bringSubviewToFront:[presentView.subviews firstObject]];
519-
// }
520-
[_myFliterMenu dismissMenu];
521-
}else
522-
{
523-
[self fliterBtnClose:FALSE];
524-
_myFliterMenu.selectNum=_selectNum>=3?_selectNum+1:_selectNum;
525-
// UIView *presentView=[[[UIApplication sharedApplication].keyWindow rootViewController] view];
526-
// [presentView bringSubviewToFront:[presentView.subviews firstObject]];
527-
UIView *presentView=[[[UIApplication sharedApplication].keyWindow rootViewController] view];
528-
[_myFliterMenu showMenuAtView:presentView];
529-
// [_myFliterMenu showMenuAtView:self.view];
530-
}
531-
}
532-
533-
534439
#pragma mark Search
535440
- (void)searchItemClicked:(id)sender{
536441
[_mySearchBar setX:20];
@@ -552,8 +457,7 @@ - (void)searchItemClicked:(id)sender{
552457
[_mySearchBar becomeFirstResponder];
553458
}
554459

555-
-(void)searchAction
556-
{
460+
-(void)searchAction{
557461
if (!_mySearchDisplayController) {
558462
_mySearchDisplayController = ({
559463
UISearchDisplayController *searchVC = [[UISearchDisplayController alloc] initWithSearchBar:_mySearchBar contentsController:self];
@@ -570,20 +474,14 @@ -(void)searchAction
570474
}
571475
}
572476

573-
574-
-(void)goToSearchVC
575-
{
477+
-(void)goToSearchVC{
576478
[self closeFliter];
577479
[self closeMenu];
578480
SearchViewController *vc=[SearchViewController new];
579-
// [self.navigationController pushViewController:vc animated:NO];
580-
581481
BaseNavigationController *searchNav=[[BaseNavigationController alloc]initWithRootViewController:vc];
582482
[self.navigationController presentViewController:searchNav animated:NO completion:nil];
583483
}
584484

585-
586-
587485
#pragma mark Table
588486
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
589487
return 1;
@@ -616,10 +514,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
616514

617515
#pragma mark UISearchBarDelegate
618516

619-
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
620-
{
621-
// [self searchAction];
622-
// [searchBar setShowsCancelButton:YES animated:YES];
517+
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{
623518
[self goToSearchVC];
624519
return NO;
625520

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /