Skip to content

Commit 4b1e5b3

Browse files
committed
Add support files
1 parent 0fff5c1 commit 4b1e5b3

File tree

131 files changed

+5994
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+5994
-0
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: objective-c
2+
osx_image: xcode7.3
3+
branches:
4+
only:
5+
- master
6+
- develop
7+
env:
8+
- LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8
9+
before_install:
10+
- gem install xcpretty -N
11+
script:
12+
- set -o pipefail
13+
- xcodebuild -project ESTabBarControllerExample/ESTabBarControllerExample.xcodeproj -scheme "ESTabBarControllerExample" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 6" ONLY_ACTIVE_ARCH=NO test | xcpretty -c
14+
- pod lib lint --quick

ESTabBarController.podspec

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Pod::Spec.new do |s|
3+
s.name = "ESTabBarController"
4+
s.version = "1.0.0"
5+
s.summary = "An easy way to customize tabBarController and tabBarItem."
6+
s.description = "Highly customizable tabBarController and tabBarItem, you can easily customize ui style or add animation etc . Using swift!"
7+
s.homepage = "https://github.com/eggswift/ESTabBarController"
8+
9+
s.license = { :type => "MIT", :file => "LICENSE" }
10+
s.authors = { "lihao" => "lihao_ios@hotmail.com"}
11+
s.social_media_url = "https://github.com/eggswift/"
12+
s.platform = :ios, "8.0"
13+
s.source = {:git => "https://github.com/eggswift/ESTabBarController.git", :tag => "1.0.0"}
14+
s.source_files = 'ESTabBarController/**/*.{swift}'
15+
s.requires_arc = true
16+
end
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//
2+
// ESTabBarBadge.swift
3+
//
4+
// Created by egg swift on 16/4/7.
5+
// Copyright (c) 2013-2016 ESPullToRefresh (https://github.com/eggswift/ESTabBarController)
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
//
25+
// README.md
26+
// 通过设置badgeValue参数,实现TabBarItem上的单一小红点或带数字的小红点
27+
// badgeValue为可选类型
28+
// 当badgeValue为nil时,内部处理成小圆点类型
29+
// 当badgeValue为""时,内部处理成小圆点类型
30+
// 当badgeValue为任意非空字符串时,内部处理成带数字的小圆点类型
31+
// 通过maximumSize设置字符串最大大小,超过截取
32+
// 通过minimumSize设置字符串最小大小,即只有红点情况
33+
34+
import Foundation
35+
import UIKit
36+
37+
public enum ESTabBarBadgeType {
38+
case Default, Number
39+
}
40+
41+
public class ESTabBarBadge: UIView {
42+
public var maximumSize: CGSize = CGSize(width: 28.0, height: 16.0)
43+
public var minimumSize: CGSize = CGSize(width: 6.0, height: 6.0)
44+
public var badgeValue: String? {
45+
didSet {
46+
badgeLabel.text = badgeValue
47+
updateSubviewsLayout()
48+
}
49+
}
50+
private var badgeLabel: UILabel = {
51+
let label = UILabel.init()
52+
label.font = UIFont.systemFontOfSize(11.0)
53+
label.textColor = UIColor.whiteColor()
54+
label.textAlignment = .Center
55+
return label
56+
}()
57+
58+
private override init(frame: CGRect) {
59+
super.init(frame: frame)
60+
// 大红色
61+
backgroundColor = UIColor.redColor()
62+
// 添加Label
63+
addSubview(badgeLabel)
64+
}
65+
66+
convenience init(frame: CGRect, type: ESTabBarBadgeType) {
67+
var size: CGSize!
68+
switch type {
69+
case .Default:
70+
size = CGSize(width: 6.0, height: 6.0)
71+
break
72+
case .Number:
73+
//最小也得是圆的
74+
size = CGSize(width: 16.0, height: 16.0)
75+
break
76+
}
77+
self.init(frame: CGRect.init(origin: frame.origin, size: size))
78+
}
79+
80+
required public init?(coder aDecoder: NSCoder) {
81+
fatalError("init(coder:) has not been implemented")
82+
}
83+
84+
85+
public override func didMoveToSuperview() {
86+
super.didMoveToSuperview()
87+
if superview != nil {
88+
self.updateSubviewsLayout()
89+
}
90+
}
91+
92+
public override func layoutSubviews() {
93+
super.layoutSubviews()
94+
if layer.cornerRadius != self.bounds.size.height / 2.0 {
95+
layer.cornerRadius = self.bounds.size.height / 2.0
96+
}
97+
}
98+
99+
100+
func updateSubviewsLayout() {
101+
var size = frame.size
102+
if badgeValue?.characters.count > 0 {
103+
size = badgeLabel.sizeThatFits(CGSize.init(width: CGFloat.max, height: self.frame.size.height))
104+
size.width = ceil(min(maximumSize.width, max(maximumSize.height, size.width + 6.0)))
105+
size.height = ceil(maximumSize.height)
106+
} else {
107+
size = self.minimumSize
108+
}
109+
/*
110+
self.snp_remakeConstraints { (make) in
111+
if let superview = superview {
112+
make.top.equalTo(superview).offset(4.0)
113+
make.centerX.equalTo(superview).offset(12)
114+
}
115+
make.size.equalTo(size)
116+
}
117+
*/
118+
setNeedsLayout()
119+
}
120+
121+
}

0 commit comments

Comments
 (0)