Skip to content

Commit eb94ea0

Browse files
committed
Updated readme and increased version.
1 parent ca533c4 commit eb94ea0

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,41 @@ segmentedControl.useShadow = true
103103

104104
```
105105

106+
You can add image instead of title.
106107

108+
![](Resources/Image_with_attributes.png)
109+
110+
```swift
111+
// ask segmented control to initialize all elements internally
112+
segmentedControl.layoutSubviews()
113+
114+
let imageAttachment = NSTextAttachment()
115+
imageAttachment.image = image
116+
imageAttachment.bounds = CGRect(x: 0, y: -5, width: 20, height: 20)
117+
118+
let attributes = NSAttributedString(attachment: imageAttachment)
119+
120+
segmentedControl.changeAttributedTitle(attributes, selectedTile: attributes, atIndex: atIndex)
121+
```
122+
123+
Or combine them.
124+
125+
```swift
126+
// ask segmented control to initialize all elements internally
127+
segmentedControl.layoutSubviews()
128+
129+
let imageAttachment = NSTextAttachment()
130+
imageAttachment.image = image
131+
imageAttachment.bounds = CGRect(x: 0, y: -5, width: 20, height: 20)
132+
133+
let attributes = segmentedControl.attributedDefaultTitles.first?.mutableCopy() as! NSMutableAttributedString
134+
attributes.append(NSAttributedString(attachment: imageAttachment))
135+
136+
let selectedAttributes = segmentedControl.attributedSelectedTitles.first?.mutableCopy() as! NSMutableAttributedString
137+
selectedAttributes.append(NSAttributedString(attachment: imageAttachment))
138+
139+
segmentedControl.changeAttributedTitle(attributes, selectedTile: selectedAttributes, atIndex: atIndex)
140+
```
107141
## Contribution
108142

109143
Feel free to Fork, submit Pull Requests or send us your feedback and suggestions!
16.3 KB
Loading

TTSegmentedControl.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ s.license = 'MIT'
77
s.name = "TTSegmentedControl"
88
s.summary = "An elegant, animated and customizable segmented control for iOS."
99
s.requires_arc = true
10-
s.version = "0.4.7"
10+
s.version = "0.4.8"
1111
s.author = { "Igor Dumitru" => "[email protected]" }
1212
s.homepage = "https://tapptitude.com/"
1313
s.framework = "UIKit"

0 commit comments

Comments
 (0)