EpubReaderLight is a Swift package that that allow you to present the content of EPUB book. There are no any additional UI elements that will be showen except the book reader itself. It's implemented the way you will be able to provide a native experience for the user.
It's a Swift Package, so you need to do the following:
- Open
File
in Xcode menu - Open
Swift Packages
- Choose
Add Package Dependency...
option - In the
Enter package repository URL
field paste this URL:https://github.com/pichukov/epub-reader-light
- Choose any existing version or take it from
main
branch
Add import EpubReaderLight
to your swift file.
Create an instance of ReaderViewController
:
let readerController = ReaderViewController(theme: .dark, eventsHandler: self)
theme
: initialdark
orlight
mode for the readereventsHandler
: delegate that will handle events from reader
Class that will be injected as a delegate should conform ReaderEventsHandler
protocol.
To load the book, you need to provide a local URL:
try? await readerController.loadBook(url: url)
You also can inject a default configuration:
try? await readerController.loadBook(
url: url,
bookSavedData: BookSavedData(
theme: .light,
fontSize: 24,
font: "Avenir Next",
page: 10
)
)
theme
: initialdark
orlight
mode for the readerfontSize
: size of the font in bookfont
: font stylepage
: initial page that will be opened