|
1
|
Part of [Fabric](https://www.fabric.io/), Twitter Kit is easiest way to bring real-time conversational content to your apps. Growing an app’s user base and retaining end users can be a challenge for any developer. To keep users engaged, you need rich, unique content that feels natural to your app’s experience. |
|
2
|
|
|
3
|
To install, follow the instructions [here](https://fabric.io/kits/ios/twitterkit/install). |
|
4
|
|
|
5
|
### Show a Single Tweet |
|
6
|
|
|
7
|
To show a single Tweet, you first need to load that Tweet from the network and then create and configure a `TWTRTweetView` with that `TWTRTweet` model object. Then it may be added to the view hierarchy: |
|
8
|
|
|
9
|
```swift |
|
10
|
import TwitterKit |
|
11
|
|
|
12
|
TWTRAPIClient().loadTweetWithID("20") { tweet, error in |
|
13
|
if let t = tweet { |
|
14
|
let tweetView = TWTRTweetView(tweet: t) |
|
15
|
tweetView.center = view.center |
|
16
|
view.addSubview(tweetView) |
|
17
|
} else { |
|
18
|
print("Failed to load Tweet: \(error)") |
|
19
|
} |
|
20
|
} |
|
21
|
``` |
|
22
|
|
|
23
|
<img src="https://docs.fabric.io/apple/_images/show_tweet_compact.png" width="250"/> |
|
24
|
|
|
25
|
|
|
26
|
#### Configuring Tweet View Colors & Themes |
|
27
|
To change the colors of a Tweet view you can either set properties directly on the `TWTRTweetView` instances or on the `UIAppearanceProxy` of the `TWTRTweetView`. |
|
28
|
|
|
29
|
```swift |
|
30
|
// Set the theme directly |
|
31
|
tweetView.theme = .Dark |
|
32
|
|
|
33
|
// Use custom colors |
|
34
|
tweetView.primaryTextColor = .yellowColor() |
|
35
|
tweetView.backgroundColor = .blueColor() |
|
36
|
``` |
|
37
|
|
|
38
|
<img src="https://docs.fabric.io/apple/_images/show_tweet_themed.png" width="250"/> |
|
39
|
|
|
40
|
|
|
41
|
|
|
42
|
Set visual properties using the `UIAppearanceProxy` for `TWTRTweetView`. |
|
43
|
|
|
44
|
``` |
|
45
|
// Set all future tweet views to use dark theme using UIAppearanceProxy |
|
46
|
TWTRTweetView.appearance().theme = .Dark |
|
47
|
``` |
|
48
|
|
|
49
|
### Show a TableView of Tweets |
|
50
|
|
|
51
|
```swift |
|
52
|
import TwitterKit |
|
53
|
|
|
54
|
class UserTimelineViewController: TWTRTimelineViewController { |
|
55
|
|
|
56
|
override func viewDidLoad() { |
|
57
|
super.viewDidLoad() |
|
58
|
|
|
59
|
let client = TWTRAPIClient.clientWithCurrentUser() |
|
60
|
self.dataSource = TWTRUserTimelineDataSource(screenName: "jack", APIClient: client) |
|
61
|
self.showTweetActions = true |
|
62
|
} |
|
63
|
|
|
64
|
} |
|
65
|
``` |
|
66
|
|
|
67
|
<img src="https://docs.fabric.io/apple/_images/list_timeline.png" width="250"/> |
|
68
|
|
|
69
|
|
|
70
|
## Resources |
|
71
|
|
|
72
|
* [Documentation](https://docs.fabric.io/apple/twitter/overview.html) |
|
73
|
* [Forums](https://twittercommunity.com/c/fabric/twitter) |
|
74
|
* [Website](https://docs.fabric.io/apple/twitter/overview.html) |
|
75
|
* Follow us on Twitter: [@fabric](https://twitter.com/fabric) |
|
76
|
* Follow us on Periscope: [Fabric](https://periscope.tv/fabric) and [TwitterDev](https://periscope.tv/twitterdev) |