Skip to content

Commit

Permalink
Updates for uiview section of post
Browse files Browse the repository at this point in the history
  • Loading branch information
simlay committed Aug 21, 2020
1 parent 9fbbe84 commit 6eaa708
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 2020-08-17-use-uikit-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub extern fn run_app() {
match event {
Event::NewEvents(StartCause::Init) => {
add_label("THIS IS SOME TEXT".to_string(), root_view);
add_text_view(root_view);
println!("The app has started!");
},
Event::WindowEvent {
Expand Down Expand Up @@ -89,3 +90,33 @@ fn add_label(label_text: String, root_view: UIView) {
root_view.addSubview_(UIView(label.0));
}
}
fn add_text_view(root_view: UIView) {
use uikit_sys::{
CGRect,
CGPoint,
CGSize,
UITextView,
IUITextView,
UIView_UIViewHierarchy,
UIView_UIViewGeometry,
INSObject,
};
let _textview = unsafe {
let ui_textview = {
let view = UITextView(UITextView::alloc().init());
view.setFrame_(CGRect {
origin: CGPoint {
x: 20.0,
y: 50.0,
},
size: CGSize {
width: 200.0,
height: 40.0,
},
});
root_view.addSubview_(UIView(view.0));
view
};
ui_textview
};
}

0 comments on commit 6eaa708

Please sign in to comment.