An easy to use FAQ view for iOS written in Swift

Overview

FAQView

An easy to use FAQ view for iOS written in Swift.

  • This view is a subclass of UIView.


FAQView FAQView

Setup with CocoaPods

If you are using CocoaPods add this text to your Podfile and run pod install.

use_frameworks!
target 'Your target name'
pod 'FAQView', '~> 0.5.0'

Or Add source

Simply add FAQView.swift file to you project.

Usage

Creating a view from the code

let items = [FAQItem(question: "What is reddit?", answer: "reddit is a source for what's new and popular on the web."),
            FAQItem(question: "How is a submission's score determined?", answer: "A submission's score is simply the number of upvotes minus the number of downvotes.")]

let faqView = FAQView(frame: view.frame, title: "Top Queries", items: items)
view.addSubview(faqView)

Attributed text answers

You may use attributed text instead of plain text. Set the attributedAnswer property of items to an NSAttributedString.

Customization

// Question text color  
faqView.questionTextColor = UIColor.blue

// Answer text color
faqView.answerTextColor = UIColor.blue

// Question text font
faqView.questionTextFont = UIFont(name: "HelveticaNeue-Light", size: 15)

// View background color
faqView.viewBackgroundColor = UIColor.white

// Set up data detectors for automatic detection of links, phone numbers, etc., contained within the answer text.
faqView.dataDetectorTypes = [.phoneNumber, .calendarEvent, .link]

// Set color for links and detected data
faqView.tintColor = UIColor.red

Requirements

  • Swift 4.0
  • Xcode 9.0+
  • FAQView 0.4.x is compatible with Swift 3
  • iOS 9.0+

Author

Mukesh Thawani

Contributing

Feature requests, bug reports, and pull requests are all welcome.

License

Copyright (c) 2016-present Mukesh Thawani. Release under the MIT License.

Comments
  • Enhancement - Option to open links in in-app (SafariViewController) browser

    Enhancement - Option to open links in in-app (SafariViewController) browser

    It would be nice to have an option to open the links using SafariViewController (instead of taking the user to Safari) when user taps on the detected link.

    enhancement 
    opened by ghost 5
  • Feature Request: Image Tappable

    Feature Request: Image Tappable

    Currently, the down arrow image cannot be tapped to open/close the answer. I think many users will instinctively tap on the arrows. To make them respond to taps, the following code can be added to the tableView:cellForRowAt function.

    Before the return cell add these four lines:

        cell.indicatorImageView.tag = indexPath.section
        let gestureRecogForImage = UITapGestureRecognizer(target: self, action: #selector(FAQView.handleQuestionLabelTap(_:)))
        cell.indicatorImageView.addGestureRecognizer(gestureRecogForImage)
        cell.indicatorImageView.isUserInteractionEnabled = true
    
    enhancement 
    opened by DavidLari 5
  • Up/ down arrows don't appear

    Up/ down arrows don't appear

    I install via Cocoapods, copy / paste the code in the readme, run project and the arrows don't appear.

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        faqView()
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    func faqView() {
        let items = [FAQItem(question: "What is reddit?", answer: "reddit is a source for what's new and popular on the web."),
                     FAQItem(question: "How is a submission's score determined?", answer: "A submission's score is simply the number of upvotes minus the number of downvotes.")]
        
        let faqListView = FAQView(frame: view.frame, items: items)
        view.addSubview(faqListView)
    }
    

    simulator screen shot jan 10 2017 9 13 29 am

    help wanted 
    opened by saldous 4
  • issue with constraints

    issue with constraints

    Hi , I just tried the Demo project and I get issues with constraints when I clicked on cell (after it expand)

    Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x60000272dea0 V:|-(10)-[UILabel:0x7fa285e0a030'What is reddit?'] (active, names: '|':UITableViewCellContentView:0x7fa285e04f20 )>", "<NSLayoutConstraint:0x60000272ddb0 V:[UILabel:0x7fa285e0a030'What is reddit?']-(10)-[UITextView:0x7fa287007600'reddit is a source for wh...'] (active)>", "<NSLayoutConstraint:0x60000272dd60 V:[UITextView:0x7fa287007600'reddit is a source for wh...']-(20)-| (active, names: '|':UITableViewCellContentView:0x7fa285e04f20 )>", "<NSLayoutConstraint:0x60000272db30 UIView:0x7fa285e04ba0.height == UILabel:0x7fa285e0a030'What is reddit?'.height (active)>", "<NSLayoutConstraint:0x60000277c690 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fa285e04f20.height == 38 (active)>" )

    Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60000272ddb0 V:[UILabel:0x7fa285e0a030'What is reddit?']-(10)-[UITextView:0x7fa287007600'reddit is a source for wh...'] (active)>

    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. β‰ˆ2020-02-11 14:16:27.754909+0300 Demo-iOS[11611:178060] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x600002767b10 V:|-(10)-[UILabel:0x7fa288070790'How is a submission's sco...'] (active, names: '|':UITableViewCellContentView:0x7fa285c29cb0 )>", "<NSLayoutConstraint:0x600002767c00 V:[UILabel:0x7fa288070790'How is a submission's sco...']-(10)-[UITextView:0x7fa28083a400'A submission's score is s...'] (active)>", "<NSLayoutConstraint:0x600002767c50 V:[UITextView:0x7fa28083a400'A submission's score is s...']-(20)-| (active, names: '|':UITableViewCellContentView:0x7fa285c29cb0 )>", "<NSLayoutConstraint:0x600002767e80 UIView:0x7fa285c29710.height == UILabel:0x7fa288070790'How is a submission's sco...'.height (active)>", "<NSLayoutConstraint:0x60000272eee0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fa285c29cb0.height == 38 (active)>" )

    Will attempt to recover by breaking constraint <NSLayoutConstraint:0x600002767c00 V:[UILabel:0x7fa288070790'How is a submission's sco...']-(10)-[UITextView:0x7fa28083a400'A submission's score is s...'] (active)>

    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

    opened by X901 3
  • Scrolling Issue

    Scrolling Issue

    If there are a bunch of expanded FAQ Items and they go off the screen and I try to scroll down to the last one I can never scroll all the way to the bottom.

    This is an odd issue with the scrollview I think.

    Please let me know if there is an easy solution.

    Thanks

    opened by uknowmeright 3
  • Support Swift 5.1 and add new features

    Support Swift 5.1 and add new features

    • Add Dark Mode support Now by default it suppourt Dark mode , depend on the iOS settings

    • Add: RTL support for language like Arabic I add new property positionType user can choose .left or .right

    • Add: Swift 5.1 support

    • Fix: Constraints issue there was issue with Constraints I fixed it

    opened by X901 2
  • TextView instead of Label

    TextView instead of Label

    If anyone is interested, I have created a fork with the following enhancements:

    • Replaced the answer UILabel with a UITextView.
    • Added automatic data detection capability. Just set dataDetectorTypes property array to the types you want to detect and the detector will make them links in the answer.
    • Added answerTintColor to color foreground text color of detected links.
    • Added a new property to Items. You may initialize an item with either the answer String, or attributedAnswer as NSAttributedString. This allows the ability to add links. For example, you could give a brief answer to a question and provide a link for more information.

    I needed these features for my app. If there is interest in merging these changes into this project, let me know. Otherwise, just close this issue and I'll maintain my own fork.

    enhancement 
    opened by DavidLari 2
  • Bug with title label

    Bug with title label

    Currently, when changing configuration properties of the title label, it stores them in the configuration, but fails to apply the values to the label itself. The setters should modify the appropriate properties of the title label as shown below.

      public var titleLabelColor: UIColor! {
        get {
          return configuration.titleTextColor
        }
        set(value) {
          configuration.titleTextColor = value
          titleLabel.textColor = value    // Added this line
        }
      }
      
      public var titleLabelFont: UIFont! {
        get {
          return configuration.titleTextFont
        }
        set(value) {
          configuration.titleTextFont = value
          titleLabel.font = value    // Added this line
        }
      }
      
      public var viewBackgroundColor: UIColor! {
        get {
          return configuration.viewBackgroundColor
        }
        set(value) {
          configuration.viewBackgroundColor = value
          titleLabel.backgroundColor = value    // Added this line
        }
      }
    
    bug 
    opened by DavidLari 2
  • Podspec doesn't include Assets

    Podspec doesn't include Assets

    When installing via cocoapods, the Up/down arrow doesn't show up. Upon investigation, it appears that the Assets are not in the project. In looking at your podspec I see that you didn't include them.

    This stack overflow answer shows how to do it. http://stackoverflow.com/a/38286446/2584110

    Maybe this needs to be in the podspec:

    s.resources = "FAQView/Assets/*.xcassets"
    
    opened by DavidLari 2
  • Not installing correctly with cocoapods

    Not installing correctly with cocoapods

    When adding pod to the podfile and running pod install it doesn't seem to add the pod to the pod target properly. It generates a folder in Pods directory but not connecting it up. I ended up including FaqView.swift directly for now. I have a bunch of other cocoapods in the project, and all other installations work fine.. am I missing something? Also, the example project doesn't compile for the same reason i think, can't find the module. I'm on Xcode 9.3. Thanks!

    opened by katerynasytnykiOS 1
  • Carthage support

    Carthage support

    opened by TofPlay 1
  • Request for SwiftUI FAQ Demo

    Request for SwiftUI FAQ Demo

    I am new in SwiftUI, I want to creat FAQ view means( question answer view). In this view populate number of question and answer. When I click on anyone question, only the answer of that question is visible and not the other question. And the answer of all the questions should be hidden/Collapse.

    opened by chandangomechanic 0
Releases(0.6.0)
Owner
Mukesh Thawani
Software Engineer. Interested in machine learning.
Mukesh Thawani
Easy to use, highly customizable gauge view

GDGauge - Customizable Gauge View Requirements Xcode 11+ Swift 5 iOS 9+ Installation Swift Package Manager .package(url: "https://github.com/saeid/GDG

Saeid 74 Dec 5, 2022
Powerful and easy-to-use vector graphics Swift library with SVG support

Macaw Powerful and easy-to-use vector graphics Swift library with SVG support We are a development agency building phenomenal apps. What is Macaw? Mac

Exyte 5.9k Jan 1, 2023
An easy to use UI component to help display a signal bar with an added customizable fill animation

TZSignalStrengthView for iOS Introduction TZSignalStrengthView is an easy to use UI component to help display a signal bar with an added customizable

TrianglZ LLC 22 May 14, 2022
Easy-to-use HStack that snaps to elements on scroll.

SnapToScroll Drop-in SwiftUI-based container view for horizontal snapping. example-video.mp4 Getting Started Using SnapToScroll is straightforward. Th

null 206 Jan 7, 2023
A child view controller framework that makes setting up your parent controllers as easy as pie.

Description Family is a child view controller framework that makes setting up your parent controllers as easy as pie. With a simple yet powerful publi

Christoffer Winterkvist 246 Dec 28, 2022
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

Jogendra 1.4k Jan 4, 2023
Windless makes it easy to implement invisible layout loading view.

Windless Windless makes it easy to implement invisible layout loading view. Contents Requirements Installation Usage Looks Credits Communication Licen

ArLupin 940 Dec 22, 2022
🏞 A simple iOS photo and video browser with optional grid view, captions and selections written in Swift5.0

Introduction ?? MediaBrowser can display one or more images or videos by providing either UIImage objects, PHAsset objects, or URLs to library assets,

Kyle Yi 631 Dec 29, 2022
Cool Animated music indicator view written in Swift

Cool Animated music indicator view written in Swift. ESTMusicIndicator is an implementation of NAKPlaybackIndicatorView in Swift for iOS 8. ζœ¬δΊΊθ‘—δ½œηš„δΉ¦η±γ€ŠLa

Aufree 465 Nov 28, 2022
πŸ” Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!

YNSearch + Realm Support Updates See CHANGELOG for details Intoduction ?? Awesome search view, written in Swift 5.0, appears search view like Pinteres

Kyle Yi 1.2k Dec 17, 2022
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 772 Dec 28, 2022
Confetti View lets you create a magnificent confetti view in your app

ConfettiView Confetti View lets you create a magnificent confetti view in your app. This was inspired by House Party app's login screen. Written in Sw

Or Ron 234 Nov 22, 2022
πŸš€ Elegant Pager View fully written in pure SwiftUI.

PagerTabStripView Made with ❀️ by Xmartlabs team. XLPagerTabStrip for SwiftUI! Introduction PagerTabStripView is the first pager view built in pure Sw

xmartlabs 482 Jan 9, 2023
Show the weather effects onto view written in Swift4.2

URWeatherView What is this for? Showing some kinds of the weather effect, written in Swift4.2. This code style is the Protocol Oriented Programming. T

Urtaq 449 Dec 28, 2022
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle ✨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

patrick piemonte 600 Nov 24, 2022
An iOS Library that makes shadows management easy on UIView.

ShadowView is an iOS Shadow library that makes view's shadow implementation easy and sweet ?? ?? . Add simple shadows to add a gaussian blurred projec

Pierre 404 Dec 8, 2022
UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

Mohsan Khan 29 Sep 9, 2022
CITreeView created to implement and maintain that wanted TreeView structures for IOS platforms easy way

CITreeView CITreeView created to implement and maintain that wanted TreeView structures for IOS platforms easy way. CITreeView provides endless treevi

Cenk Işık 126 May 28, 2022
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements

SwiftUIKitView Easily use UIKit views in SwiftUI. Convert UIView to SwiftUI View Create Xcode Previews from UIView elements SwiftUI functional updatin

Antoine van der Lee 682 Dec 29, 2022