Initial commit
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// UMComSegmentedControl.h
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by umeng on 16/3/8.
|
||||
// Copyright © 2016年 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UMComSegmentedControl : UISegmentedControl
|
||||
|
||||
@property (nonatomic, strong)UIColor *selectedTitleColor;
|
||||
|
||||
@property (nonatomic, strong)UIColor *nomalTitleColor;
|
||||
|
||||
@property (nonatomic, strong)UIFont *titleFont;
|
||||
|
||||
|
||||
- (void)setfont:(UIFont *)font titleColor:(UIColor *)textColor selectedColor:(UIColor *)selectedColor;
|
||||
|
||||
@end
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// UMComSegmentedControl.m
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by umeng on 16/3/8.
|
||||
// Copyright © 2016年 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UMComSegmentedControl.h"
|
||||
|
||||
@implementation UMComSegmentedControl
|
||||
|
||||
- (instancetype)initWithItems:(NSArray *)items
|
||||
{
|
||||
self = [super initWithItems:items];
|
||||
if (self) {
|
||||
self.selectedSegmentIndex = 0;
|
||||
self.selectedTitleColor = [UIColor whiteColor];
|
||||
self.nomalTitleColor = [UIColor blueColor];
|
||||
self.titleFont = [UIFont systemFontOfSize:14];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setfont:(UIFont *)font titleColor:(UIColor *)textColor selectedColor:(UIColor *)selectedColor;
|
||||
|
||||
{
|
||||
_titleFont = font;
|
||||
_nomalTitleColor = textColor;
|
||||
_selectedTitleColor = selectedColor;
|
||||
NSDictionary *seletedDic = [NSDictionary dictionaryWithObjectsAndKeys:_selectedTitleColor,UITextAttributeTextColor, font,UITextAttributeFont ,nil];
|
||||
[self setTitleTextAttributes:seletedDic forState:UIControlStateSelected];
|
||||
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:_nomalTitleColor,UITextAttributeTextColor, font,UITextAttributeFont ,nil];
|
||||
[self setTitleTextAttributes:dic forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user