Comments (8)
Yeah, you're right: when you use Storyboards/Xibs, the init(withCoder:)
variant is called. Since theme configuration is only supported by passing in theme info to the initializer, you effectively cannot customize the theme at all.
I would hide the knowledge, tbh, and change Notepad
:
public class Notepad: UITextView {
var storage: Storage = Storage()
public var theme: Theme {
get { return storage.theme }
set { storage.theme = newValue }
}
// ...
}
That would be a more stable API that exposes theme configuration on the base object, while hiding knowledge about the implementation in Storage.
from notepad.
Oops, my bad — misread #57. Let me think on this, even though I saw your PR with programmatic themes #59, I think there should be a drag/drop way to use Notepad. Perhaps with IBInspectables, etc. I'll play around with it when I get a chance.
from notepad.
Hi, you can use a few different approaches to use Notepad with a Storyboard:
- Set a custom class of "Notepad" on the UITextView in your Storyboard.
- Use an IBOutlet to connected your UITextView to your view controller file, and then extend that UITextView.
- Add a Notepad programmatically to a connected view in an .xib file or Storyboard by initializing it and then using
someView.addSubview(notepad).
from notepad.
- Set a custom class of "Notepad" on the UITextView in your Storyboard.
This doesn't seem to work.
from notepad.
Thanks for letting me know, @rivera-ernesto. Are you getting any errors or just no result?
from notepad.
No results. I've been fighting with it yesterday. Is seems that Storage
methods never get called.
I've been trying to set the theme in viewDidLoad
(self.notepad.storage.theme = Theme("one-dark")
). For that I had to change storage
visibility to public private(set) var storage: Storage = Storage()
.
from notepad.
@DivineDominion is correct, init(withCoder:)
is called with Storyboards, so you'll have to use something like they suggested. An obvious oversight on my part, unfortunately. I think at one time I was imagining that the theme could be an IBInspectable/IBDesignable
... but alas I forgot...
Looks like this is addressed in your PR #57.
from notepad.
I was trying to "add" functionality to an existing UITextView
and noticed that it needs to be init
ialized with the custom container.
That may be the same reason why Notepad
s initialized through Storyboards don't work.
from notepad.
Related Issues (20)
- Suggestion box is too big HOT 4
- Align text in the centre HOT 2
- Carthage & Swift Package Manager support HOT 6
- Swift 4 support (on CocoaPods)? HOT 3
- 3 spaces make it not working HOT 3
- Internal Protection Level HOT 9
- Line break inside bold or italic markup leaves first part marked up HOT 1
- attribute run ranges are in inconsistent state HOT 2
- Please add the possibility to change the syntax color and clickable links. HOT 4
- macOS pod installation HOT 3
- Issue with Xcode 10.2 HOT 2
- Style boldItalics not rendered correctly HOT 9
- Unable to load your theme file. HOT 11
- Objective C support HOT 1
- Use System Font HOT 2
- Custom attributes HOT 1
- Placeholder support
- Hide markdown syntax as cursor leaves the position? HOT 4
- New release version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notepad.