{"id":15037347,"url":"https://github.com/tobedefined/tsegmentedview","last_synced_at":"2025-04-09T23:24:21.553Z","repository":{"id":56923298,"uuid":"105265963","full_name":"ToBeDefined/TSegmentedView","owner":"ToBeDefined","description":"You can use TSegmentedView create scroll page views","archived":false,"fork":false,"pushed_at":"2019-10-15T11:23:22.000Z","size":14390,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T12:03:50.188Z","etag":null,"topics":["carthage","cocoapods","scroll-events","segment","segmented-view","swift3","swift4"],"latest_commit_sha":null,"homepage":"http://t.cn/RYIqZG1","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ToBeDefined.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-29T11:41:35.000Z","updated_at":"2023-02-17T06:19:30.000Z","dependencies_parsed_at":"2022-08-21T05:20:21.089Z","dependency_job_id":null,"html_url":"https://github.com/ToBeDefined/TSegmentedView","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToBeDefined%2FTSegmentedView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToBeDefined%2FTSegmentedView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToBeDefined%2FTSegmentedView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToBeDefined%2FTSegmentedView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ToBeDefined","download_url":"https://codeload.github.com/ToBeDefined/TSegmentedView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248127173,"owners_count":21052199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","cocoapods","scroll-events","segment","segmented-view","swift3","swift4"],"created_at":"2024-09-24T20:34:23.861Z","updated_at":"2025-04-09T23:24:21.523Z","avatar_url":"https://github.com/ToBeDefined.png","language":"Swift","readme":"\n\n\u003cdiv align=\"center\"\u003e\n\nTSegmentedView\n------\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n![platform](https://img.shields.io/badge/Platform-iOS%E2%89%A58.0-orange.svg?style=flat)\u0026nbsp;\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\u0026nbsp;\n[![CocoaPods](https://img.shields.io/badge/Cocoapods-compatible-brightgreen.svg?style=flat)](http://cocoapods.org/)\u0026nbsp;\n[![Build Status](https://travis-ci.org/tobedefined/TSegmentedView.svg?branch=master)](https://travis-ci.org/tobedefined/TSegmentedView)\u0026nbsp;\n[![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/tobedefined/TSegmentedView/blob/master/LICENSE)\u0026nbsp;\n[![Join the chat at https://gitter.im/TSegmentedView/Lobby](https://badges.gitter.im/TSegmentedView/Lobby.svg)](https://gitter.im/TSegmentedView/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\u003c/div\u003e\n\n\n\u003cdiv align=\"center\"\u003e\n\n[中文文档](README_CN.md)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n![演示](images/demo.gif)\n\n\u003c/div\u003e\n\n### Features\n\n- perfectly compatible with `Objective-C` and `Swift(3/4/5)`\n- support user scorll and click tab\n- support slide back(in any tab)\n- support `Frame` and `Autolayout`, you can use `Masonry`/`SnapKit`/`NSLayoutConstraint` layout views\n- support in the ordinary `UIView` (and the non-sliding `UIView subclass View`), `UIScrollView`,` UITableView`\n- support `UITableView` add` tableHeaderView` \n- support `UITableView` to add section header view, and show that there will be no hover position is not correct\n- support custom `SegmentedControlView` (tab click) style, you can set their own animation, set their own height and so on\n\n\u003e support UIView\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"images/UIView.PNG\" width=\"30%\" height=\"30%\" /\u003e\n\u003c/div\u003e\n\n\u003e support UIScrollView\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"images/UIScrollView.PNG\" width=\"30%\" height=\"30%\" /\u003e\n\u003c/div\u003e\n\n\u003e support UITableView add tableHeaderView\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"images/UITableView.PNG\" width=\"30%\" height=\"30%\" /\u003e\n\u003c/div\u003e\n\n\u003e support UITableView add section header\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"images/sectionHeader.PNG\" width=\"30%\" height=\"30%\" /\u003e\n\u003c/div\u003e\n\n### Why wrote `TSegmentedView`\n\nNow a lot of similar framework, but still do one, mainly because most of the framework of the Internet to write the `SegmentedControlView` (that is, tab style), the other important point is that I have tried a lot of frames found` UITableView` `tableHeaderView `There will be problems, and once the section header view, hover has a problem, so I wrote this ...\n\n### Installation\n\n#### Source File\n\nIf your project uses `Swift 3/3.1` and does not use `Xcode 9`, please download `TSegmentedControlView.swift`, `TSegmentedView.swift`, `TSVExtension.swift` in the `Source` directory and put them in your project, No other configuration can be used.\n\nIf your project uses `Xcode 9`, it is recommended to use `CocoaPods` or `Carthage`.\n\n#### CocoaPods\n\n[`CocoaPods`](https://cocoapods.org/) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate `TSegmentedView` into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'TSegmentedView'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n#### Carthage\n\n[`Carthage`](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [`Homebrew`](https://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate `TSegmentedView` into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ruby\ngithub \"tobedefined/TSegmentedView\" ~\u003e 1.1.0\n```\n\nRun `carthage update` to build the framework and drag the built `TSegmentedView.framework` into your Xcode project.\n\n### How to use\n\n- swift\n\n```swift\nimport TSegmentedView\n```\n\n- Objective-C\n\n```objc\n#import \u003cTSegmentedView/TSegmentedView-Swift.h\u003e\n```\n\nYou can see the specific use of the demo, the following is a specific introduction\n\n#### Compliance Protocol: `TSegmentedViewDelegate`\n\n```swift\nfunc segmentedViewTitles(in segmentedView: TSegmentedView) -\u003e [String]\n\nfunc segmentedView(_ view: TSegmentedView, viewForIndex index: Int) -\u003e UIView\n```\n\n- the first function is to `TSegmentedView` no tab of the title assignment, array count is the number of tabs\n- The second function is to give each tab a view\n\noptional protocol functions\n\n```swift\n// 1 \n@objc optional func segmentedView(_ view: TSegmentedView, didShow index: Int) -\u003e Void\n\n// 2.1 (Swift 3.2/4)\n@objc optional func segmentedViewSegmentedControlView(in segmentedView: TSegmentedView) -\u003e (UIView \u0026 TSegmentedControlProtocol)\n// 2.2 (Swift 3/3.1)\n@objc optional func segmentedViewSegmentedControlView(in segmentedView: TSegmentedView) -\u003e UIView\n\n// 3\n// default is 0\n@objc optional func segmentedViewFirstStartSelectIndex(in segmentedView: TSegmentedView) -\u003e Int\n\n// 4\n// default is nil\n@objc optional func segmentedViewHeaderView(in segmentedView: TSegmentedView) -\u003e UIView\n\n// 5\n// default is segmentedViewHeaderView height\n@objc optional func segmentedViewHeaderMaxHeight(in segmentedView: TSegmentedView) -\u003e CGFloat\n\n// 6\n// default is segmentedViewHeaderView height\n@objc optional func segmentedViewHeaderMinHeight(in segmentedView: TSegmentedView) -\u003e CGFloat\n\n// 7\n// when scroll top or bottom, change the titles view height , will run this method\n@objc optional func segmentedView(_ view: TSegmentedView, didChangeHeaderHeightTo height: CGFloat) -\u003e Void\n\n```\n\n- Optional function usage\n\n  1. Function is in the index corresponding to the view will be called, will be called every time when select or scroll to the index\n  2. The function returns the `SegmentedControlView` of the definition, which needs to be `UIView` that conforms to the `TSegmentedControlProtocol` protocol\n  3. function returns `TSegmentedView` created when the choice of which tab (the default choice of the first tab -\u003e index = 0)\n  4. return headerView (default is nil)\n  5. Set the maximum height of the header (the default size of the header view's frame height)\n  6. Set the minimum height of the header (the default is the same as the maximum height)\n  7. When the header height changes, this function is called, allowing some animations to be made according to the new hight\n\n\n### about `TSegmentedControlProtocol`\n\nYou can see the definition of this protocol in `TSegmentedView.swift`\n\n```swift\n@objc protocol TSegmentedControlProtocol: class {\n    func reloadData(with titles: [String]) -\u003e Void\n    func userScrollExtent(_ extent: CGFloat) -\u003e Void\n    func setAction(_ actionBlock: ((_ index: Int) -\u003e Void)?) -\u003e Void\n}\n```\n\n- Why define `TSegmentedControlProtocol`:\n\n    \u003e `TSegmentedView` allows users to customize `SegmentedControlView` instead of having to use `TSegmentedControlView`'\n- how to customize `SegmentedControlView`\n\n    \u003e The first view created must be a subclass of `UIView`, then conform to the `TSegmentedControlProtocol` protocol and implement these three methods\n\n- `func reloadData (with titles: [String]) -\u003e Void`\n\n    \u003e This method in the `TSegmentedView` `reloadData` when the call back, this method needs to be updated to achieve the corresponding tab to create a delete display and other operations, `titles` is `TSegmentedControlView` proxy method to return the array\n\n- `func userScrollExtent (_ extent: CGFloat) -\u003e Void`\n\n    \u003e This method in the `TSegmentedView` slide (the user manually slide) when the call back, this method needs to update the corresponding tab of the view display style or custom animation, `extent` the value of the current sliding ratio. For example, there are three tabs, the range is `0.0 ~ 2.0`\n\n- `func setAction(_ actionBlock: ((_ index: Int) -\u003e Void)?) -\u003e Void`\n\n    \u003e This method requires you to save `actionBlock` and call` actionBlock` when you click tab, then, will scroll to the corresponding tab's view. (Initially considered to be in the protocol to define a `actionBlock` variable, in order to be compatible with `Objective-C`, it is defined as a function.)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobedefined%2Ftsegmentedview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobedefined%2Ftsegmentedview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobedefined%2Ftsegmentedview/lists"}