iOS 自定義分段選擇器


 

UIFont *titleFont = [UIFont systemFontOfSize:13];

// 狀態1 

TKSegementedItemStatus *compositeNormal = [TKSegementedItemStatus statusWithTitle:@"綜合" titleColor:[UIColor blackColor] titleFont:titleFont image:nil backgroundImage:nil becomeCurrentStatusBlock:^{
        NSLog(@"綜合默認狀態");
    }];

 

// 狀態2

TKSegementedItemStatus *compositeSelected = [TKSegementedItemStatus statusWithTitle:@"綜合" titleColor:[UIColor redColor] titleFont:titleFont image:nil backgroundImage:nil becomeCurrentStatusBlock:^{
        NSLog(@"綜合剛剛被選中");
    }];

 

// 狀態3

TKSegementedItemStatus *compositeOthers = [TKSegementedItemStatus statusWithTitle:@"綜合" titleColor:[UIColor green] titleFont:titleFont image:nil backgroundImage:image3 becomeCurrentStatusBlock:^{
        NSLog(@"價格降序狀態");
    }];

 

TKSegementedItem *compositeItem = [TKSegementedItem itemWithNormalStatus:compositeNormal selectedStatus:compositeSelected otherStatus:compositeOthers];

TKSegementedView *segementedView = [TKSegementedView segementedViewWithSegementedItem:compositeItem, volumeItem, priceItem, filterItem, nil];

 

segementedView.frame = CGRectMake(0, 64, self.view.bounds.size.width, 35);

segementedView.verticalDividerInset = UIEdgeInsetsMake(10, 0, 10, 0);

[self.view addSubview:segementedView];

 

https://github.com/tomatoK/TKSegementedView


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM