百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-swiftui

> 编程语言
开源

react-native-swiftui 这个项目是为了研究我们可以做些什么来利用 SwiftUI 来替代 UIKit,以作为 iOS 的 UI 组件。

194 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

react-native-swiftui 这个项目是为了研究我们可以做些什么来利用 SwiftUI 来替代 UIKit,以作为 iOS 的 UI 组件。

react-native-swiftui

This project is to research what we can do to take advantage of using SwiftUI as a replacement for UIKit being the iOS native framework used by React Native to render user interfaces. Especially, it would make it possible to use React Native on other Apple platforms such as macOS, watchOS, tvOS and iOS widgets.

Reimplemented React Native components

View

  • Applying layout metrics calculated by Yoga from provided position-related styles
  • Other styles
    • backgroundColor
    • color
    • opacity
    • borderLeft (borderLeftWidth and borderLeftColor)

Text

  • Styles excluding these inherited from View
    • fontSize
    • fontWeight
    • fontStyle (only italic so far)
    • textAlign (no justify support)
  • Props
    • numberOfLines prop
    • ellipsizeMode prop
      • head
      • center
      • tail
      • clip (no such equivalent in SwiftUI, but it can be implemented the other way)

Button

  • React Native's button heavily depends on Touchables relying on responder events that might be tricky to reimplement, so we have our own Button component instead.
  • Events
    • onPress
    • onActiveStateChange

TextInput

  • Styles inherited from View
  • Props
    • placeholder
    • value
    • partially multiline, read more below
  • Events
    • onChange
    • onFocus
    • onBlur
    • onEndEditing
  • SwiftUI's TextField doesn't provide much functionalities yet. Under the hood it still uses UITextField from UIKit so hopefully it will be improved soon. So far it isn't yet possible to:
    • Focus/blur on demand
    • Change tappable area — the default area is very narrow and doesn't include given padding
    • Get cursor position
    • Read text selection
    • For multiline input we can use TextEditor however it doesn't meet our requirements even more as it doesn't support any events and placeholder text.

Switch

  • Props
    • value
    • partially trackColor (only false state is supported by SwiftUI yet)
  • Events
    • onChange

ScrollView

  • A lot of properties known from UIScrollView are missing in SwiftUI, so we have our own ScrollView component.
  • There is no convenient way to get onScroll event other than just adding drag gesture.
  • Scroll to specified point within the view is not provided yet. However, as it let us scroll to a subview with specified ID, we can omit this limitation by rendering empty points filling the entire axis with an ID being its (X,Y) position which is how scrollTo command is implemented.
  • Props
    • axes that takes vertical/horizontal/both as an argument.
    • showsIndicators — as opposed to UIScrollView, for 2-directional scroll views, we cannot specify different arguments for specific axis.
  • Commands
    • scrollTo(options: { y: number, animated: boolean }) — works only for vertical scrolls, as it would be a significant performance hit in the current implementation to support both axes.

Image

  • Implemented only for network assets.
  • Only source property is supported. Accepts the same value types as Image from React Native.

Graphical Effects

Animation

Animates changes to all animatable values within this view (including its subviews).

  • Props
    • type (easeIn, easeOut, easeInOut, linear)
    • duration (in seconds)

Shadow

Adds a shadow with given radius, offsetX, offsetY, opacity and color to children views.

Mask

Masks children views using the alpha channel of the views provided by shape prop.

Shapes

SVG-like shape components. Shapes are not managed by Yoga which means they have their own layouting mechanism (configurable with alignment, offsetX and offsetY props) that makes them positioned absolutely to the parent view. As opposed to SVG, our shapes can contain children.

Common shape props: fill, alignment, offsetX, offsetY, stroke, strokeWidth, strokeLineCap, strokeLineJoin, strokeDashes, strokeDashPhase.

Rect

Additional props: width, height

Circle

Additional props: radius

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言