•  


GitHub - lifution/FSPopoverView: An iOS customizable view that displays a popover view.
Skip to content

lifution/FSPopoverView

Repository files navigation

FSPopoverView

Platform Swift 5.x ObjC incompatible Version Status Carthage compatible Swift Package Manager license MIT

A library to present popovers.

Demo

Custom content
List (Light)
List (Dark)
List (Custom item)
List (Horizontal layout)

Support

  • Custom content
  • Arrow direction
  • Hidden Arrow
  • Custom border
  • Custom shadow
  • Custom transition animation
  • Custom list item
  • Dark mode (iOS13+)
  • Global appearance
  • Arrow direction priority
  • List appends/removes item
  • Compatible with screen rotation

Requirements

  • iOS 12+
  • Swift 5
  • Xcode 15+

Installation

CocoaPods (recommended)

pod
 'FSPopoverView'
github 
"
lifution/FSPopoverView
"

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding FSPopoverView as a dependency is as easy as adding it to the dependencies value of your Package.swift or the Package list in Xcode.

dependencies: 
[

    .
package
(
url
:
 "
https://github.com/lifution/FSPopoverView.git
"
)

]

Copy manually

Download or clone the repository, drag the folder Source into your project, and tick Copy items if needed and Create groups .

Usage

  • If you need to customize the content, use FSPopoverView, implements the dataSource and return the contents.
let
 popoverView
 =
 FSPopoverView
(
)

popoverView
.
dataSource 
=
 self

popoverView
.
present
(
fromBarItem
:
 barItem
)


// data source

extension
 viewController
:
 FSPopoverViewDataSource
 {

    
    func
 backgroundView
(
for popoverView
:
 FSPopoverView
)
 ->
 UIView
?
 {

        let
 view
 =
 UIView
(
)

        view
.
backgroundColor 
=
 .
yellow
        
return
 view
    
}

    
    func
 contentView
(
for popoverView
:
 FSPopoverView
)
 ->
 UIView
?
 {

        return
 contentView
    
}

    
    func
 contentSize
(
for popoverView
:
 FSPopoverView
)
 ->
 CGSize
 {

        return
 .
init
(
width
:
 100.0
,
 height
:
 100.0
)

    }

    
    func
 containerSafeAreaInsets
(
for popoverView
:
 FSPopoverView
)
 ->
 UIEdgeInsets
 {

        return
 view
.
safeAreaInsets
    
}

    
    func
 popoverViewShouldDismissOnTapOutside
(
_ popoverView
:
 FSPopoverView
)
 ->
 Bool
 {

        return
 true
    
}

}
  • If you need to display a list, use FSPopoverListView , which provides FSPopoverListTextItem by default. FSPopoverListView is data-driven. Inherits FSPopoverListItem and FSPopoverListCell if you need to customize the item.
let
 features
:
 [
Feature
]
 =
 [
.
copy
,
 .
message
,
 .
db
,
 .
qr
,
 .
settings
]

let
 items
:
 [
FSPopoverListItem
]
 =
 features
.
map
 {
 feature 
in

    let
 item
 =
 FSPopoverListTextItem
(
)

    item
.
image 
=
 feature
.
image
    item
.
title 
=
 feature
.
title
    item
.
isSeparatorHidden 
=
 false
    item
.
selectedHandler 
=
 {
 item 
in

        guard 
let
 item 
=
 item 
as?
 FSPopoverListTextItem
 else
 {

            return

        }

        print
(
item
.
title 
??
 "
"
)

    }

    item
.
updateLayout
(
)

    return
 item
}

items
.
last
?
.
isSeparatorHidden 
=
 true
let
 listView
 =
 FSPopoverListView
(
)

listView
.
items 
=
 items
listView
.
present
(
fromRect
:
 sender
.
frame
.
insetBy
(
dx
:
 0.0
,
 dy
:
 -
6.0
)
,
 in
:
 view
)
  • Use FSPopoverView.fs_appearance() to customize default values for popover view.
func
 application
(
_ application
:
 UIApplication
,
 didFinishLaunchingWithOptions launchOptions
:
 [
UIApplication
.
LaunchOptionsKey
 :
 Any
]
?
 =
 nil
)
 ->
 Bool
 {

    do
 {

        let
 appearance
 =
 FSPopoverView
.
fs_appearance
(
)

        appearance
.
showsArrow 
=
 false
        appearance
.
showsDimBackground 
=
 true
        
...

    }

    return
 true
}
  • For more information on how to use, see the example project under the repository.

License

FSPopoverView is available under the MIT license. See the LICENSE file for more info.

- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본