在React Native上更改按钮字体大小

web*_*g13 7 button reactjs react-native react-navigation

我正在尝试在我的本机应用程序上更改Button字体大小,但出现错误。有人知道该怎么做吗?谢谢。

小智 12

您可以将 react-native-elements 与titleStyleprops 一起使用。

import {Input, Button} from 'react-native-elements';

<Button
   onPress={this.addPicture}
   titleStyle={{
       color: "white",
       fontSize: 16,
   }}
   buttonStyle={{
       backgroundColor: "white",
       borderRadius: 60,
       flex: 1,
       height: 30,
       width: 30,  
   }}

   title="+"
/>
Run Code Online (Sandbox Code Playgroud)


Ary*_*NYC 6

我有一种感觉,你没有Text在你的内部使用元素Touchable

import React from 'react';
import { TouchableWithoutFeedback, Text } from 'react-native';

export default function ComponentName() {
  return (
    <TouchableWithoutFeedback>
      <Text style={{ fontSize: 24 }}>Button Text</Text>
    </TouchableWithoutFeedback>
  );
}
Run Code Online (Sandbox Code Playgroud)


小智 5

不幸的是,根据文档(https://reactnative.dev/docs/button),您无法更改按钮的字体大小。您可以更改的唯一样式道具是color.

<Button
  onPress={onPressLearnMore}
  title="Learn More"
  color="#841584"
  accessibilityLabel="Learn more about this purple button"
/>
Run Code Online (Sandbox Code Playgroud)