小编Dan*_*dan的帖子

CGContextDrawLinearGradient导致EXC_BAD_ACCESS

我正在配置我的BEMSimpleLineGraph并且除了线性渐变着色之外已经能够成功完成.在提供的示例Obj-C项目中引用此代码之后

CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
    size_t num_locations = 2;
    CGFloat locations[2] = { 0.0, 1.0 };
    CGFloat components[8] = {
        1.0, 1.0, 1.0, 1.0,
        1.0, 1.0, 1.0, 0.0
    };
    self.myGraph.gradientBottom = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations);
Run Code Online (Sandbox Code Playgroud)

并在Swift中将其转录为此内容:

let colorspace:CGColorSpaceRef = CGColorSpaceCreateDeviceRGB()
        let num_locations:size_t = 2
        var locations: [CGFloat] = [0.0, 1.0]
        var components: [CGFloat] = [
            1.0, 1.0, 1.0, 1.0,
            1.0, 1.0, 1.0, 0.0
        ]

       self.myGraph.gradientBottom = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations)
Run Code Online (Sandbox Code Playgroud)

一切都正确构建但引发包含的BEMLine.m文件中的EXC_BAD_ACCESS内存错误,在此行停止

CGContextDrawLinearGradient(ctx, self.bottomGradient, CGPointZero, CGPointMake(0, CGRectGetMaxY(fillBottom.bounds)), 0);
Run Code Online (Sandbox Code Playgroud)

我已经包含了obj-c桥接头,添加了CoreGraphics框架,在Storyboard中相应ViewController的属性窗格中启用了底色,引用了Apple的开发页面以确保所有参数的正确数据类型,但我仍然会变干.在检查错误相似性时,我也意识到尝试绘制顶部线性渐变也会出现同样的错误.错误似乎在于试图绘制渐变的Obj-C代码,但我再次无法做什么.

core-graphics objective-c linear-gradients swift bemsimplelinegraph

5
推荐指数
1
解决办法
511
查看次数

围绕自定义 li 项目符号创建 CSS 边框

我试图弄清楚是否可以在我作为 li 的自定义项目符号导入的图像周围合并 css 边框:

ul {
  list-style: none;
  margin-right: 0;
  padding-left: 0;
  list-style-position: inside;
}

ul > li {
  align-content: center;
  display: flex;
  margin: 5px 0;
  padding-left: 1em;
  text-indent: -1em;
}

ul li:before {
  /* I'm a different image but found a similar 
   sized one online for demonstration 
   purposes seen below */
   
  content: url("https://www.dicentral.com/css/assets/imgs/Flag_Nation_france.png");
  border: 1px solid grey;
}
Run Code Online (Sandbox Code Playgroud)
<ul>
   <li>Get to know the business</li>
   <li>Get to know people (stakeholders, key players, cross-functional partners, etc.)</li>
   <li>Learn how the team's …
Run Code Online (Sandbox Code Playgroud)

html css border html-lists

5
推荐指数
1
解决办法
7205
查看次数

使用 Material-UI 在 TableCell 中嵌入菜单

我想在TableCell内部实现Google 的 Material UI 菜单项,如他们的文档所示,如下所示:

在此输入图像描述

这是我目前的方法:

import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import {
  Grid,
  IconButton,
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableRow,
  Paper,
  Menu,
  MenuItem,
  Button,
} from '@material-ui/core';
import { ExpandLess, ExpandMore } from '@material-ui/icons';

const styles = theme => ({});

const Questions = ({ data, classes, openMenu, anchorEls, handleClose }) => {
  const CustomTableCell = withStyles(theme => ({
    head: {
      backgroundColor: theme.palette.common.black,
      color: theme.palette.common.white,
    }, …
Run Code Online (Sandbox Code Playgroud)

html javascript css reactjs material-ui

1
推荐指数
1
解决办法
9011
查看次数