search

Home  >  Q&A  >  body text

ios - 请问这种带尖角的view有什么好的实现方法

伊谢尔伦伊谢尔伦2866 days ago1405

reply all(8)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:51:55

    The programmer’s solution is to create a square view; the background color is the same as the main frame color. Then; rotate this square view 90 degrees. Add to main box. Just specify the location. In other words, this style is made up of two views.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:51:55

    Make a bubble image, and then put a tableView in it. After setting the fixed constraints and slicing of the image, can you try this? ?

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:51:55

    You can draw one, which saves cutting resources, is more efficient, and is easy to reuse.

    - (UIView *)arrowView{
        if (!_arrowView) {
            // draw
            CGSize size = CGSizeMake(kDefaultArrowWeight, kDefaultArrowHeight);
            UIBezierPath *path = [[UIBezierPath alloc] init];
            [path moveToPoint:CGPointMake(size.width / 2.0, 0)];
            [path addLineToPoint:CGPointMake(0, size.height)];
            [path addLineToPoint:CGPointMake(size.width, size.height)];
            path.lineWidth = 1.0;
            
            CAShapeLayer *arrowLayer = [CAShapeLayer layer];
            arrowLayer.path = path.CGPath;
            
            _arrowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
            _arrowView.layer.mask = arrowLayer;
            _arrowView.backgroundColor = self.contentViewBackgroundColor;
        }
        return _arrowView;
    }

    reply
    0
  • PHPz

    PHPz2017-04-18 09:51:55

    A triangular imageview is attached to the UIView, and a tableview is attached to it. There is no problem with scrolling like this, and there is no problem if you want to adjust the position of the imageView.

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 09:51:55

    HTML:

    <p class="test_triangle_border">
        <a href="#">三角形</a>
        <p class="popup">
            <span><em></em></span>测试
        </p>
    </p>
    

     

    CSS:

    .test_triangle_border{
        width:200px;
        margin:0 auto 20px;
        position:relative;
    }
    .test_triangle_border a{
        color:#333;
        font-weight:bold;
        text-decoration:none;
    }
    .test_triangle_border .popup{
        width:100px;
        background:#cf0;
        padding:10px 20px;
        color:#333;
        border-radius:4px;
        position:absolute;
        top:30px;
        left:30px;
        border:1px solid #333;
    }
    .test_triangle_border .popup span{
        display:block;
        width:0;
        height:0;
        border-width:0 10px 10px;
        border-style:solid;
        border-color:transparent transparent #333;
        position:absolute;
        top:-10px;
        left:50%;/* 三角形居中显示 */
        margin-left:-10px;/* 三角形居中显示 */
    }
    .test_triangle_border .popup em{
        display:block;
        width:0;
        height:0;
        border-width:0 10px 10px;
        border-style:solid;
        border-color:transparent transparent #cf0;
        position:absolute;
        top:1px;
        left:-10px;
    }
    

    This is an answer I have given to others, please change it according to your needs

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:51:55

    This is a control, exclusive for iPad. It’s called UIPopoverController.

    reply
    0
  • 阿神

    阿神2017-04-18 09:51:55

    If it is iOS8, you can use UIPopoverPresentationController

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:51:55

    The artist needs a picture to solve

    reply
    0
  • Cancelreply